7 Commits

Author SHA1 Message Date
Ivan FB
79e5dc64c6
fix(pool): deinit context resources in full teardown
destroyFFIContext stopped/joined the worker threads and marked the slot for
rebuild, but no longer deinited the context — so the six ThreadSignalPtr fds
were orphaned every full teardown (the exact leak this path exists to prevent),
and the still-initialised Lock + event registry/queue locks were left live.

createFFIContext's rebuild path (initialized == false) reruns
initContextResources, which calls initLock / initEventRegistry / initEventQueue
and installs fresh signals over the stale handles — re-initialising a live lock
is UB. Restore the deinitContextResources() call (as the pre-recycle code did)
before marking the slot uninitialised so the rebuild starts from clean state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 17:30:08 +02:00
Ivan FB
0e176bd5eb
fix(ffi): set up foreign-thread GC in entry procs; recycle/event cleanup
- Call initializeLibrary() (setupForeignThreadGc) in the `.ffi.` request
  wrapper and in add/remove_event_listener so a foreign (Go) caller thread
  has an initialised Nim heap before any allocation ($reqTypeName /
  $eventName / registry ops). Without it such a thread segfaults in the
  allocator under GC pressure — the production unwrap SIGSEGV.
- recycleContext resets the event registry/queue + stuck flag on park so a
  reused pool slot starts clean.
- ffiDtor doc/cleanup for the async recycle ABI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 11:28:48 +02:00
Ivan FB
24cf796fcd
fix(pool): recycle contexts to stop per-cycle fd leak (#74) 2026-06-11 15:33:18 +02:00
Gabriel Cruz
9b3cde7674
feat: move user event code to a dedicated event thread (#69) 2026-06-09 11:35:04 -03:00
Gabriel Cruz
54c41a3e62
refactor(ffi): event thread scaffolding + FFIContext lifecycle split (#71) 2026-06-08 11:46:16 -03:00
Ivan FB
496a341466
Event registry wiring (#49) 2026-05-27 22:26:39 +02:00
Ivan FB
6d31fa30bd
use fixed array of ctx to avoid consuming all fds (#14) 2026-05-13 00:02:23 +02:00