internal/lockedfile: keep objects alive while stopping cleanups
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m38s
Test / Hakurei (push) Successful in 3m49s
Test / ShareFS (push) Successful in 3m59s
Test / Hpkg (push) Successful in 4m23s
Test / Sandbox (race detector) (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 5m54s
Test / Flake checks (push) Successful in 1m43s
All checks were successful
Test / Create distribution (push) Successful in 1m0s
Test / Sandbox (push) Successful in 2m38s
Test / Hakurei (push) Successful in 3m49s
Test / ShareFS (push) Successful in 3m59s
Test / Hpkg (push) Successful in 4m23s
Test / Sandbox (race detector) (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 5m54s
Test / Flake checks (push) Successful in 1m43s
Fixes https://go.dev/issues/74780. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -94,6 +94,11 @@ func (f *File) Close() error {
|
||||
|
||||
err := closeFile(f.osFile.File)
|
||||
f.cleanup.Stop()
|
||||
// f may be dead at the moment after we access f.cleanup,
|
||||
// so the cleanup can fire before Stop completes. Keep f
|
||||
// alive while we call Stop. See the documentation for
|
||||
// runtime.Cleanup.Stop.
|
||||
runtime.KeepAlive(f)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user