Skip to content

Conversation

@mitchellh
Copy link
Owner

This fixes a number of block-related issues in the codebase, as noted below. This is a breaking change. The API is changing to support these fixes.

  1. Our flags had an off-by-one which meant our copy/dispose helpers were never being called. This caused other issues too like the refcount system not working properly so blocks would leak.

  2. We were heap allocating a block but setting it as a stack allocated block. The proper behavior is to allocate it on the stack then let the ObjC runtime handle the copying via the compiler-rt.

  3. Add manual copy/release helpers for blocks in case blocks are being passed around Zig code. This is needed because the Zig compiler won't automatically instrument the code like LLVM does for C-family languages.

  4. Our copy helper that called _Block_object_assign was passing the wrong pointer value for the first parameter meaning reference counts weren't being incremented properly.

This fixes a number of block-related issues in the codebase, as noted
below. **This is a breaking change.** The API is changing to support
these fixes.

1. Our flags had an off-by-one which meant our copy/dispose helpers were
   never being called. This caused other issues too like the refcount
   system not working properly so blocks would leak.

2. We were heap allocating a block but setting it as a stack allocated
   block. The proper behavior is to allocate it on the stack then let
   the ObjC runtime handle the copying via the compiler-rt.

3. Add manual copy/release helpers for blocks in case blocks are being
   passed around Zig code. This is needed because the Zig compiler won't
   automatically instrument the code like LLVM does for C-family
   languages.

4. Our copy helper that called `_Block_object_assign` was passing the
   wrong pointer value for the first parameter meaning reference counts
   weren't being incremented properly.

Co-authored-by: qwerasd205 <qwerasd205@users.noreply.github.com>
@mitchellh mitchellh force-pushed the push-omvolkzqwvkr branch from 4760492 to e70f386 Compare July 2, 2025 21:23
@mitchellh mitchellh merged commit c9e917a into main Jul 2, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants