[agent/codex:gpt-5.3-codex-spark] Read docs/RFC.md fully. Find ONE feature described in the sp... #25
2 changed files with 9 additions and 4 deletions
2
scope.go
2
scope.go
|
|
@ -79,7 +79,7 @@ func (s *Scope) FreeAll() {
|
|||
}
|
||||
|
||||
if !s.freed.CompareAndSwap(false, true) {
|
||||
return
|
||||
panic("cgo.Scope.FreeAll: double-free detected")
|
||||
}
|
||||
|
||||
s.lock.Lock()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ func TestScopeFreesAllResources(t *testing.T) {
|
|||
}
|
||||
|
||||
scope.FreeAll()
|
||||
scope.FreeAll() // idempotent
|
||||
assertPanics(t, "double-free", func() {
|
||||
scope.FreeAll()
|
||||
})
|
||||
|
||||
if !buffer.IsFreed() {
|
||||
t.Fatal("expected buffer to be freed")
|
||||
|
|
@ -57,7 +59,7 @@ func TestScopeIsFreedTracksLifecycle(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestScopeCloseIsSafeAndIdempotent(t *testing.T) {
|
||||
func TestScopeClosePanicsOnDoubleFree(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var nilScope *Scope
|
||||
|
|
@ -79,7 +81,10 @@ func TestScopeCloseIsSafeAndIdempotent(t *testing.T) {
|
|||
t.Fatalf("expected close to return nil, got %v", err)
|
||||
}
|
||||
|
||||
scope.Close()
|
||||
assertPanics(t, "double-free", func() {
|
||||
scope.Close()
|
||||
})
|
||||
|
||||
if !buffer.IsFreed() {
|
||||
t.Fatal("expected buffer to be freed after close")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue