mirror of
https://github.com/logos-messaging/nim-ffi.git
synced 2026-06-21 08:49:34 +00:00
initializeLibrary ran NimMain only on the thread that won `initialized.exchange(true)`; concurrent first-time callers fell straight through and used a half-initialized Nim runtime — a heap-corrupting race when multiple foreign (e.g. Go) threads create the first context at once. Add an `initDone` flag the winner sets after NimMain; the others spin until it is set before proceeding. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>