akbasic_renumber() keeps two 9999-entry static locals, so it is not reentrant #12

Open
opened 2026-08-02 19:04:18 -04:00 by tachikoma · 0 comments
Collaborator

Source: TODO.md §6 item 29 (at 9151438)

src/renumber.c holds map[] and rewritten[] at file scope, and
akbasic_runtime_check_targets() adds a static scratch buffer beside them.

That is against the no-file-scope-mutable-state rule in MAINTENANCE.md, and it means
RENUMBER and the target prescan are not reentrant across two akbasic_Runtimes in one process
-- the exact thing that rule exists to guarantee.

They are static because they will not fit on a default stack, which is the same reason
akbasic_Runtime itself is too big for one.

The honest fix is to hang them off the runtime like every other pool, which costs another ~2.5MB
inline per interpreter for something used by one verb and one prescan.
Recorded rather than done,
because "make it reentrant" and "do not grow the runtime by a third for a scratch buffer" are both
right and picking between them is a decision.

Files: src/renumber.c, src/runtime.c (akbasic_runtime_check_targets)


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md §6 item 29 (at 9151438) `src/renumber.c` holds `map[]` and `rewritten[]` at file scope, and `akbasic_runtime_check_targets()` adds a `static` scratch buffer beside them. **That is against the no-file-scope-mutable-state rule in `MAINTENANCE.md`**, and it means `RENUMBER` and the target prescan are not reentrant across two `akbasic_Runtime`s in one process -- **the exact thing that rule exists to guarantee.** They are `static` because they will not fit on a default stack, which is the same reason `akbasic_Runtime` itself is too big for one. **The honest fix is to hang them off the runtime like every other pool, which costs another ~2.5MB inline per interpreter for something used by one verb and one prescan.** Recorded rather than done, because "make it reentrant" and "do not grow the runtime by a third for a scratch buffer" are both right and picking between them is a decision. **Files:** `src/renumber.c`, `src/runtime.c` (`akbasic_runtime_check_targets`) --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.1.x milestone 2026-08-02 19:04:18 -04:00
tachikoma added the defectdesign-decisionblast-radius:mediumstatus::grooming labels 2026-08-02 19:04:18 -04:00
Sign in to join this conversation.