fix(scope): disable cgo finalizers after manual cleanup

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-03 19:41:21 +00:00
parent 446a02fad9
commit 0aeba0a5db
2 changed files with 2 additions and 0 deletions

View file

@ -71,6 +71,7 @@ func (b *Buffer) Free() {
panic("cgo.Buffer.Free: double-free detected")
}
runtime.SetFinalizer(b, nil)
C.free(b.pointer)
b.pointer = nil
b.data = nil

View file

@ -81,6 +81,7 @@ func (s *Scope) FreeAll() {
if !s.freed.CompareAndSwap(false, true) {
panic("cgo.Scope.FreeAll: double-free detected")
}
runtime.SetFinalizer(s, nil)
s.lock.Lock()
buffers := s.buffers