Repository navigation
Comparing an Opaque with Opaque | null no longer overflows the stack - #536
Merged
Merged
Conversation
`next != this.current`, with `current: Opaque | null`, crashed the compiler with 0xC00000FD and no message. LogicOp, for a nullable left operand and a union without a tag on the right, called itself again with the union's base type as the LEFT type and the union still as the right one - the same branch, forever. The base type now replaces the right type, as for a union on the left. Reported in docs/bugs/native-ts-graphics-findings.md (issue 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompare-recursion # Conflicts: # tslang/test/tester/CMakeLists.txt
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.
Problem
Comparing an
Opaquewith anOpaque | nullcrashed the compiler with a stack overflow (0xC00000FD) and printed nothing:Reported in
docs/bugs/native-ts-graphics-findings.md, issue 1 (docs/bugs/ntg_opaque_nullable_compare.ts).Cause
LogicOp(UnaryBinLogicalOrHelper.h), in the branch for a nullable left operand (isNullableTypeNoUnion) and a union on the right that needs no tag, called itself again withleft, baseType, right, rightType: the union's base type went in as the left type, and the right type was still the union. That reaches the same branch again, forever. A WinDbg stack of the debug build showedLogicOp<CmpIOp, ..., ne, ...>calling itself until the stack ran out.The minimal trigger is any reachable
opaque != (opaque | null). A function that is never called is dropped before lowering, so it doesn't crash.Fix
Pass the base type as the right type:
left, leftType, right, baseType. The mirrored branch for a union on the left already did it this way.Testing
00opaque_nullable_compare.ts(compile + JIT): the issue's class,OpaquevsOpaque | nullwith the union on either side, and a class vsClass | nullwith===/!==. The current release crashes with0xC00000FD.🤖 Generated with Claude Code