Skip to content

builtins.c onto the slot API (#1665 arm D B3) - #1712

Merged
InauguralPhysicist merged 4 commits into
mainfrom
arm-d-B3
Oct 11, 2026
Merged

InauguralPhysicist merged 4 commits into
mainfrom
arm-d-B3

Conversation

@InauguralPhysicist

Copy link
Copy Markdown
Collaborator

Part of #1665: batch B3 of the arm D step-2 design. All of src/builtins.c moves onto the slot API and joins the migrated-files gate. Storage stays Value**.

Contents

  • Codex round 1: the migration. Reads go through slots and views, direct-child returns use list_get_return, copies use list_append_slot, and moves and sorts use list_move/list_sort.
  • Codex round 2: the rehearsal build caught a SIGSEGV in [104] lib/supervise. The cause was a numeric view kept in a chunk's constant pool (stack-use-after-return under rehearsal + ASan). The same class was fixed at 10 more sites, plus a sort_by owned-argument leak.
  • A read-only blind review of everything migrated so far (B0–B3) found two blocking bugs, both reachable from ordinary programs and missed by the suite. Both are fixed here, with regressions:
    • get_at use-after-free. It returned a string/list/dict element through list_get_return, but that element is a grandchild of the argument list, which vm_borrow_scan never compensates. It now uses list_get_owned. The suite only ever called get_at on numbers.
    • dispatch returned a pointer into its own dead frame: a numeric view passed to a builtin that returns its argument (num). Release printed garbage and then hit SIGSEGV. A number argument now goes in as a fresh owned box.
    • Same class, also fixed:
      • classify: view storage that died with its if block;
      • chan_clone_rec and values_equal_impl: the depth-64 cap treated scalars by pointer;
      • two CASE(DISPATCH) exits that skipped eigs_view_check.
  • [0fh] tests/test_slot_escape_regress.eigs is red on the unfixed tree under ASan: heap-use-after-free for get_at and stack-use-after-return for dispatch. It is green with the fixes.

Gates (run locally)

check result
Ir vs B2 dmg_shape +0.00001%, idxset +0.00002%, perf −0.003%
tape identity identical
jit-smoke pass
jit_diff 257 programs pass
ASan, detect_leaks=1 330/330 over 36 sections (core, json, string, sort, [0fh]), leak tally 0
release suite all green except the pre-existing [99d] (#1708); the shape pin my get_at fix changed is re-pinned, and [99s] re-passes
rehearsal suite the coalesce double free B2 left in rehearsal is gone; the rest is [99d] and the pre-existing [70d] (#1709)

Also filed from the review: #1710 (a list_insert_at overflow, already on main) and #1711 (BUILTIN_*_VIEW uses have no escape check).

🤖 Generated with Claude Code

https://claude.ai/code/session_01KC99CmwatKssQYggkBCgwF

xxxxxxxxxxxxx and others added 4 commits October 10, 2026 21:51
…onst pool, desc_isolate_const, set_at/insert/copy_into); sort_by owned-arg leak

Rehearsal [104] lib/supervise SIGSEGV was a numeric EigsView facade
retained in a chunk constant pool by vm_build_chunk_desc_body
(stack-use-after-return under rehearsal+ASan). Audit of every get_ref /
view site in builtins.c fixed the same class at 10 sites.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KC99CmwatKssQYggkBCgwF
…eturn) + 4 same-class sites

Read-only blind review of the migrated files (B0-B3) against the
retained-view / ownership class:

- get_at (1-D and 2-D) returned list_get_return for a GRANDCHILD of its
  argument list; vm_borrow_scan only compensates direct children, so a
  string/list/dict element came back unowned (heap-use-after-free under
  ASan at teardown). Now list_get_owned.
- builtin_dispatch passed a numeric stack view to the inner builtin; one
  that returns its argument (num) handed back a pointer into dispatch's
  dead frame (garbage + SIGSEGV in release; stack-use-after-return under
  ASan). A number argument now goes in as a fresh owned box.
- classify: a BUILTIN_LIST_VIEW compound literal died at its if-block
  but was read after it; the view now has function-scope storage.
- chan_clone_rec / values_equal_impl: the depth-64 cap now applies to
  containers only; scalars are copied / compared by value at any depth.
- vm.c CASE(DISPATCH): two exits after fn_view was filled lacked
  eigs_view_check.

tests/test_slot_escape_regress.eigs ([0fh]): red on the unfixed tree
under ASan (both bugs), green with the fixes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KC99CmwatKssQYggkBCgwF
…get_owned; no policy change)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KC99CmwatKssQYggkBCgwF
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T02:57:39.406222Z fa018aa PR opened
🔒 Security Review ✅ Completed 2026-10-11T02:57:27.300089Z fa018aa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Oct 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks


Comparing arm-d-B3 (fa018aa) with main (b02d427)

Open in CodSpeed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa018aa63a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/builtins.c
Comment on lines +4068 to 4069
slot_decref(list_slot(list, idx));
list_set_owned(list, idx, val);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Release overwritten numeric storage before replacing it

When built with EIGS_SLOT_REHEARSAL, list_slot(list, idx) converts the stored boxed number into an immediate slot, and slot_decref is therefore a no-op; list_set_owned then overwrites the actual items[idx] pointer without releasing its box. Repeated numeric set_at calls consequently leak memory unboundedly (the same release pattern also appears in the newly migrated copy_into, truncate, remove, and insert paths), so the storage-owning element must be released rather than the normalized read slot.

Useful? React with 👍 / 👎.

@InauguralPhysicist
InauguralPhysicist added this pull request to the merge queue Oct 11, 2026
Merged via the queue into main with commit 1d127dd Oct 11, 2026
32 checks passed
@InauguralPhysicist
InauguralPhysicist deleted the arm-d-B3 branch October 11, 2026 03:21
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.

2 participants