Skip to content

TSLANG 226: -mm=own string in a tuple twice freed twice; fixes from the Debug-compiler suite - #1064

Merged
ASDAlexander77 merged 2 commits into
mainfrom
hardening-1129
Nov 29, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
hardening-1129

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

TSLANG 226: a double free under -mm=own, and fixes from running the suite on a Debug compiler.

-mm=own

  • One string put into a tuple twice was freed twice. <[V, V]>[value, value] yielded by a generator (it reads its state's slot twice) and const p = <[string, string]>[s, s] gave the tuple two owners of one string, and releasing the tuple gave it back twice: the program hung or crashed at exit. This is how a Set.entries() returning [v, v] crashed. Each repeat of a string in a tuple, whether the same value or a read of the same place, now gets its own copy after the analysis. An object given twice is still refused, as a use after its move.

Debug compiler (153 of 10,139 tests failed once the local Debug LLVM was rebuilt with the current MSVC)

  • A generator's return() result literal had no source span, so its storage name came from an empty one. About 80 generator tests stopped on loc_->pos != loc_->_end. It now takes the body's span.
  • A cast of an interface, or of null | V for a @value type V, to null reached castLLVMTypes' "review usage" stop (class_to_interface_null, value_missing_niche). A value seen as null is now the null pointer.
  • When a closure's function type was matched against another function type, its captures parameter was compared with the other type's first parameter (generic_arrow_any). It is now skipped, as a receiver is.
  • const { 0: a } = t called IntegerAttr::getInt() on an si32 key (declarationsAndAssignments).
  • resolveModuleFile assigned a path its own parent, which is a view into itself (ambient_module_import). That is undefined behaviour in Release too.
  • x.w ??= v on a @weak field read its view after storing the right side had erased it (own_weak_field_logical).
  • tsbindgen -o - closed stdout, which its stream does not own (LLVM's ShouldClose assert).

Rerun by name on the Debug compiler, 139 of the 153 pass. Still open:

  • own_counted_list_cut_in_step crashes under a Debug compiler's JIT, though its exe and the Release compiler's JIT print the right result.
  • A Debug-only timeout.
  • The Debug-tree setup failures from 11-13: an optimized exe linked against the tree's debug-CRT runtime.

Also

Validation

  • New test 00tuple_repeated_string in all four models. It segfaults under own with the previous compiler.
  • Leak probe of the generator tuple, 2M rounds: flat, equal to rc.
  • The DefaultLib suite with this compiler passes in gc, rc, none and own.
  • The full Release ctest was not run locally; CI runs it.

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits November 29, 2026 01:07
…; fixes for the Debug-compiler suite

- -mm=own: `<[V, V]>[value, value]` yielded by a generator (two reads of its state's slot) and
  `const p = <[string, string]>[s, s]` gave the tuple two owners of one string, and its release
  gave it back twice: the program hung or crashed at exit (a Set's entries()). After the analysis
  each repeat of a string in a tuple - the same value, or a read of the same place with nothing
  stored between - is a copy of its own (copyRepeatedTupleStrings).
- Debug compiler, 153 of 10,139 tests failed on the rebuilt Debug LLVM:
  - a generator's return() result literal had no source span (its `.obj` name from an empty one):
    the body's span now; ~80 generator tests stopped on `loc_->pos != loc_->_end`;
  - a cast of an interface, or of `null | V` of a @value V, to `null` reached castLLVMTypes'
    "review usage": a value seen as `null` is the null pointer;
  - a closure's function type had its captures compared with the other's first parameter: they are
    skipped, as a receiver is;
  - `const { 0: a } = t` called IntegerAttr::getInt() on an `si32` key;
  - resolveModuleFile assigned a path its own parent, a view into itself (UB in Release too);
  - `x.w ??= v` of a @weak field read its view after storing the right side erased it;
  - `tsbindgen -o -` closed stdout, which its stream does not own.

Test 00tuple_repeated_string (all models).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit dd7dfa2 into main Nov 29, 2026
8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the hardening-1129 branch November 29, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant