Repository navigation
TSLANG_ISSUES: 21, a C string result isn't copied when its .d.ts came through an import - #762
Merged
Merged
Conversation
… through an import #575's copy of a C function's `string` result is skipped when the `declare function` is in a .d.ts that an imported module also references (isForeignCall checks the module the declaration was recorded with). The raw char* then becomes a program string again: aliased buffers under gc, C++ memory counted and freed under rc (native_ts_graphics's SampleGame crashed on Android). Repro run on pre-alpha111, the IR, where to look and a suggested regression test. 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.
Adds issue 21 to
TSLANG_ISSUES.md. Documentation only; there is no compiler change here.The bug: #575 copies a C function's
stringresult. That copy is skipped when thedeclare functionis in a.d.tsthat a module the file imports also references.Effect: the raw
char*becomes a program string again.-mm=gc, stored results share C's buffer.-mm=rc, retaining one writes a count into C's memory and releasing it frees C's memory. This crashed native_ts_graphics's SampleGame on Android: "Scudo ERROR: misaligned pointer when deallocating".The entry contains:
strerror, run on pre-alpha111, with the right and wrong output;StringCopy;tsretvon the raw pointer);isForeignCallinMLIRGenImpl.hchecks the module the declaration was recorded with (MLIRGenFunctions.cpp:972);🤖 Generated with Claude Code