ReviewOS

home-lang/home

fix(ts): release partially initialized type pools on allocation failure

#498
Closed chris opened this 8 days ago ·
8 days ago

Allocation-failure testing for #494 exposed two pre-existing initialization cleanup gaps. Pool.init appends reserved entries to multiple independently allocated columns, but did not deinitialize earlier columns if a later append failed. Interner.init then reserves the large header table, but did not release its newly constructed Pool if that reservation failed.

New exhaustive initialization allocation-failure tests reproduce leaks with the original code (two failed tests; the first failing path leaves 144 allocated bytes unfreed). Add error cleanup at each ownership boundary and keep both allocation-failure regressions. This is required for transactional type transfer under memory pressure, not a timing improvement. Refs #494/#480/#487/#416.

8 days ago

Fixed and pushed in 99a8b78. Pool.init now releases partially initialized columns; Interner.init releases the pool if initial header reservation fails. Both exhaustive initialization allocation-failure tests pass.

Two separate before-fix probes confirm both ownership gaps: the original code leaks 144 bytes on the first failed column append; with Pool cleanup alone, failure at interner header reservation leaks 3,072 bytes in 21 allocations. Logs: bench/vs_tsgo/results/type-transfer.FHPXSf/initialization-before.log and reserve-before.log. The final initialization-complete.log passes both tests (plus the module root). These are error-path ownership fixes, not measured speedups.

The new type-transfer fault tests also exercise cleanup and removal of unpublished intern keys. Cross-file type integration remains under #494/#480/#487; no benchmark has been readmitted.

Sign in to comment on this issue.