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-05-11 19:21:40 -03:00
2026-06-18 11:47:22 +02:00

nim-ffi

Allows exposing Nim projects to other languages

Example

examples/nim_timer is now a self-contained Nimble project that imports nim-ffi directly. Use cd examples/nim_timer && nimble install -y ../.. && nimble build to compile the example.

Description
Allows exposing Nim projects to other languages
Readme
Languages
Nim 87.9%
Smarty 5.9%
C++ 4.8%
CMake 1.4%