Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add
runtime.KeepAlive
to keep alive descriptors
Without them, when we pass the result of Fd() into unix.Syscall, Go runtime is free to call finalizer set in os.newFile. More info [here](golang/go#34810). The proper fix is to either: 1. Use unix.Open/unix.Close as descriptors (ints) everywhere in the Device code. This should hide fd's from Go runtime. 2. Use os.File.SyscallConn().Control which guarantees that descriptor survives. This will also do not put fd's into the blocking mode. Otherwise, even with os.File.Close it's not guaranteed that runtime.SetFinalizer will not come for `os.File.file`. Signed-off-by: Dmitriy Matrenichev <[email protected]>
- Loading branch information