Ivan FB 342fefa623
fix(context): pin myLib as a GC root under refc
myLib lives in non-GC `createShared` memory, so under --mm:refc a
GC-managed lib object stored there is invisible to the cycle collector
and gets reclaimed mid-operation under sustained request load — a
use-after-free that crashes deep in the lib (e.g. a held chronos
AsyncLock). Take a GC_ref once a handler installs myLib (tracked by
FFIContext.myLibRefd) and GC_unref in freeLib so a later recycle/create
can re-pin. Guarded to refc + ref types; orc tracks it precisely.

Also wrap freeLib's `=destroy` in try/except: it is conservatively typed
as raising, and recycleContext (its async caller) is `raises: []`, so the
library would not compile under orc/arc without this.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 20:11:39 +02:00
..
2026-04-27 21:22:45 +02:00
2026-05-08 14:14:16 -03:00