Repository navigation
Conversation
AArch64 image startup created the callback pthread key only when the program had callback thunks. Every may-callback C call publishes the thread's callback state under that key (callbackState reads it through callbackKey()), with or without a callback in the program, so a program whose only may-callback calls take no callback ran with an uncreated key: pthread_setspecific failed and the call threw "callback state registration failed". The key is now created when the program has thunks or any module imports tint:callback-key, as x86-64 startup already does. On main the zlib codecs only worked because unused allocator closures in the program kept a callback thunk alive; removing dead closures (PR #17) exposed the bug as a RangeError from deflateSync. tools/native-ffi.test.ts: a may-callback call (abs as MayCallback<i32>) in a program without callbacks; it exits 70 without this change and 42 with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a latent AArch64 image-startup bug. Under PR #17 it surfaced as the macOS gate failure
node:zlib sync codecs ... (copying), exit 70.Bug
pthread_key_create) only when the program had callback thunks.callbackState(), which callscallbackKey().pthread_setspecificfailed, and the call threwRangeError: callback state registration failed.callback-keyaccess is emitted.On main,
node:zlibonly worked because unused allocator closures in the program kept a callback thunk alive. PR #17 makes unusedfunction-newremovable. That dropped those closures, anddeflateSync("")then threw the RangeError.Fix
packages/codegen/src/aarch64/startup.ts: create the key when the program has thunks or when any module importstint:callback-key, matching x86-64.How it was found
function-newonly allocates and checks the environment descriptor.deflateSync(""). Its error-message classification matchedcallback state registration failed.Validation
tools/native-ffi.test.ts:absdeclared asMayCallback<i32>, in a program with no callbacks. On main without the fix it exits 70 under LLDB; with the fix it returns 42.zlibnative tests intools/native-ffi.test.tspass under LLDB on this branch, both GC variants:zlibcodecsqsortcallbackszliballocator callbacks🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.