Repository navigation
@value T | null of a one-pointer T; rc conditional with nested @value literals - #763
Merged
Merged
Conversation
…pointer
A `T | null` kept without a tag (MLIRTypeHelper::getValueNullNiche) was laid out as its largest
member. When T's only field is a class, T's `{ptr}` is no larger than null's `ptr`, the first of
the two won, and the union became a bare pointer: comparing it with null extracted a field the
pointer does not have (a tslang crash), and casting T into it left an
unrealized_conversion_cast. Such a union is now laid out as T (TSLANG_ISSUES 22).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ral holds a branch temporary
`c ? { one: { h: new H() } } : ...` of a @value type holding a @value type: the branch gave its
new H back before the receiver after the conditional retained the literal, so H was freed under
it (heap corruption, 0xC0000374, pre-alpha112 too). consumeConditionalResults made the branch
retain the literal it yields only when the literal's own fields held a branch temporary; it now
looks into fields holding another literal the branch built.
Test: tests/00conditional_nested_record_literal_temporary.ts (gc, and rc/none through the corpus).
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.
Two fixes around
@valuetypes.TSLANG_ISSUES 22:
T | nullof a@valuetype whose only field is a classA
T | nullstored without a tag (MLIRTypeHelper::getValueNullNiche, #760) was given its largest member's LLVM type. A one-pointer T ({ptr}) is the same size as null'sptr, the first one won, and the union became a bare pointer:== null/if (v)crashed tslang (0xC0000005) and passing T to aT | nullparameter failed withLLVM Translation failed for operation: builtin.unrealized_conversion_cast. The UnionType conversion now lays such a union out as T. This unblocks native_ts_graphics (one-handle@valuewrappers taken asX | null).Test:
value/value_missing_niche_one_field.ts(gc, rc, none).rc: a conditional whose branches build nested
@valueliteralsc ? { one: { h: new H() } } : ...under-mm=rc: each branch released its newHbefore the retain after the conditional, so the program freed it and then used it (heap corruption 0xC0000374; pre-alpha112 too).consumeConditionalResultsmade the branch retain its literal only when the literal's own fields held a branch temporary; it now also looks into fields that hold another literal built in the same branch.Test:
tests/00conditional_nested_record_literal_temporary.ts(gc, and rc/none through the corpus); it fails on pre-alpha112 withassertion failed: sum.Release ctest: 6572/6572.
🤖 Generated with Claude Code