Skip to content

fix: container-builtin reference leaks (builtins.c) - #235

Merged
InauguralPhysicist merged 1 commit into
mainfrom
fix/builtin-container-leaks
Jun 18, 2026
Merged

fix: container-builtin reference leaks (builtins.c)#235
InauguralPhysicist merged 1 commit into
mainfrom
fix/builtin-container-leaks

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

Four builtins build a fresh list/dict per element and append it to an output list. The inner fields used list_append_owned/dict_set_owned, but the OUTER append of the finished container used plain list_append (which increfs), so the builtin's own ref on row/pair/r was never released and leaked one container per element:

builtin_scan_tokens list_append(out, row) -> _owned
builtin_scan_int_tokens list_append(out, row) -> _owned
builtin_tokenize_with_names list_append(result,pair) -> _owned
builtin_nearest_in_range_all list_append(result,r) -> _owned

(scan_tokens was a sibling of the traced leakers, same shape, not exercised by a counted test — fixed for consistency.)

Clears test_builtin_indirect + test_coverage_gaps (counted) and the marker-only test_string_math. Harness leak tally 8 -> 6.

Release 1941/1941, ASan 1941/1941 (tally 6).

What does this PR do?

Checklist

  • make test passes locally
  • New builtins have signature comments and docs in docs/BUILTINS.md
  • New library functions follow conventions in docs/STDLIB.md
  • New examples have a comment header explaining what they demonstrate
  • CHANGELOG.md updated (if user-facing change)

Four builtins build a fresh list/dict per element and append it to an
output list. The inner fields used list_append_owned/dict_set_owned, but
the OUTER append of the finished container used plain list_append (which
increfs), so the builtin's own ref on row/pair/r was never released and
leaked one container per element:

  builtin_scan_tokens            list_append(out, row)    -> _owned
  builtin_scan_int_tokens        list_append(out, row)    -> _owned
  builtin_tokenize_with_names    list_append(result,pair) -> _owned
  builtin_nearest_in_range_all   list_append(result,r)    -> _owned

(scan_tokens was a sibling of the traced leakers, same shape, not exercised
by a counted test — fixed for consistency.)

Clears test_builtin_indirect + test_coverage_gaps (counted) and the
marker-only test_string_math. Harness leak tally 8 -> 6.

Release 1941/1941, ASan 1941/1941 (tally 6).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@InauguralPhysicist
InauguralPhysicist merged commit a0859eb into main Jun 18, 2026
11 checks passed
@InauguralPhysicist
InauguralPhysicist deleted the fix/builtin-container-leaks branch June 18, 2026 21:28
InauguralPhysicist added a commit that referenced this pull request Jun 19, 2026
… recovery

Patch release on top of 0.16.0. Highlights:
- Remote HTTP DoS fixed (Content-Length SEGV; missing _GNU_SOURCE → 64-bit
  pointer truncation) and the implicit-declaration class hard-errored in the
  build (#239/#240).
- ASan leak tally driven 10 → 4 (spawn-thread floor) across the runtime,
  HTTP code routes, container builtins, and the store extension
  (#234/#235/#236/#233).
- OSR/JIT coverage for observed-assign loops recovered: #211's conservative
  scanner bail replaced by the real fix — reset the OP_POP last_imm peephole
  at forward-jump targets — so those loops OSR-compile again (~34%, #231).
- Docs: clarified the implicit-`n` parameter shadows an outer `n` (#241,
  not a bug).

Also repairs CHANGELOG drift: commit 8fe0731 had accidentally deleted the
`## [0.16.0] — 2026-06-18` header, folding released 0.16.0 content back into
[Unreleased]. The header is restored (with its summary), the windowed-predicate
+ #212/#213/#214 entries are reattributed to 0.16.0 (their code shipped in the
v0.16.0 tag), and everything post-tag is grouped under the new [0.16.1].

VERSION 0.16.0 → 0.16.1. Release 1943/1943; ASan 1943/1943, leak tally 4.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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