Repository navigation
An Opaque out of an any is as wide as the value in the box - #789
Merged
Merged
Conversation
`<Opaque><any>0` read 8 bytes out of a box holding a 4-byte s32: the padding after it became the pointer's high bytes. Only a zeroing allocator (the collector) left it 0; under -mm=rc, none and own on Linux the "null" pointer was garbage, and pthread_create crashed on it as its attribute argument. Unboxing to Opaque now reads the box's recorded size and keeps that many bytes, zero-extended. Other unboxes are unchanged. 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.
<Opaque><any>0read 8 bytes out of a box holding a 4-bytes32, so the padding after the value became the pointer's high bytes.-mm=rc,noneandownon Linux the "null" pointer was garbage.pthread_createcrashed when it was passed as the attribute argument (found while writing the TSLANG 29 tests in @cdecl C callbacks (TSLANG 29); a generic sees no local of its caller (TSLANG 30) #788).Fix (
AnyLogic::UnboxAny): when the result type isOpaque, the unbox reads the box's recorded size (ANY_SIZE) and keeps that many bytes, zero-extended. The 8-byte read stays inside the box, because the data field starts 8-aligned. Every other unbox, including classes and strings, keeps its plain load.Tests
00any_to_opaque_narrow.ts, in all four models, JIT and compiled. It checks that<Opaque><any>0is null after the heap has been dirtied, and thatu8,u16,s32andu64values keep their exact bit patterns.00tslang_issue_29_pthread.ts.🤖 Generated with Claude Code