Repository navigation
Array literal of a runtime array and a constant one read past the constant; own: s32->s64 union element; rc: delete of a value box - #1102
Merged
Conversation
…stant; own: s32 to s64 union element cast in place; rc: delete of a value box frees it - `[["a" + i, "b"], ["c", "d"]]`: `["c", "d"]` is a const_array, which widens to the string[] the other element is, so the element types matched and no cast was made: the constant's data was stored as the array, and reading it read past the global (every model). An element whose type differs from the element type, other than a literal, is now cast. - -mm=own: `[["a", 301349860000], ["c", 0]]` is an array of (string | s64)[] and (string | s32)[]; the element of the s32 one was cast through `__cast`, whose result borrows, and own refused to keep it (`for (const [k, v] of data)`). A member that widens into a number member of the target (s32 -> s64, an integer -> a wider float) is cast in place by the tag, as `string | s32` -> `string | number` is. - -mm=rc: `delete i` of `new (TypeOf<1>)()` (a value_ref) released nothing - the type has no release routine - and the block leaked. It is freed (no one counts it). ASan corpus 124 -> 130 of 154 clean; full ctest (WSL ASan) 10455/10455. 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.
These are fixes from the next round of the ASan corpus sweep. The corpus goes from 124 to 130 of 154 programs clean.
An array literal of a runtime array and a constant one (every model)
[["a" + i, "b"], ["c", "d"]], then any read of an element (data[1],for (const row of data),const [x, y] = data[1]). ASan reported a global-buffer-overflow.["c", "d"]is aconst_array<string, 2>, which widens to thestring[]the other element is. Because the widened types matched, the literal made no cast, and the constant's raw data was stored where an array belongs. Reading it read past the global.-mm=own: a
string | s32element read asstring | s64[["a", 301349860000], ["c", 0]]is an array of(string | s64)[] | (string | s32)[], as the An array literal of arrays with different element types is an array of their union #1093 ruling types it. Reading the(string | s32)[]member's element converted it through the generated.castfunction, whose result borrows its argument. Own refused to keep that result infor (const [k, v] of data)anddata.forEach(([k, v]) => ...).string | s32→string | numberalready was (rc/own leaks and refusals: builtin on a new array, object literals to a call, destructured literal, union spread, lent results #1098). That coverss32→s64(integers of the same signedness, no narrower) and an integer or float into a wider float.-mm=rc:
deleteof a box of a value typelet i = new (TypeOf<1>)(); delete i;. Under rc,deletereleases, butvalue_ref<T>has no release routine, so the block leaked.Tests and results
tests/00array_of_arrays_const_element.ts: gc, rc, none and own; JIT and compile.sanitize/leaks_more.ts: gainsarraysOfArrays, under rc and own, with and without--di.Still not clean (24)
any[k];[head, ...tail]of objects;return thisfrom a function expression;[[...t], ...];view()of a global.Date,consoleandReflectare missing because the probes compile with--no-default-lib.counterObjliteral under own;using_dispose_throws: a throw from a nested dispose skips releases, as its test documents.t_dp5: mixesi64,s64ands32and passes numbers to...string[], which tsc rejects.🤖 Generated with Claude Code