Ivan FB d815ea3462
fix: pass WaitGroup as cgo.Handle, not a raw stack pointer
sdsCall stored &wg (a pointer to a stack sync.WaitGroup) in C memory
(SdsResp.ffiWg) and the result callback dereferenced it from the nim-ffi
thread while the caller was parked in wg.Wait(). That violates the cgo
pointer rules: the GC can relocate the parked goroutine's stack, leaving
the C-held pointer dangling, which corrupts memory under GC pressure.

Pass the WaitGroup as a runtime/cgo.Handle (a stable uintptr token)
instead, and resolve it back to *sync.WaitGroup in the callback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 04:01:44 +02:00
..
2025-12-22 16:45:14 +00:00