Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add runtime.KeepAlive to keep alive descriptors #97

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

DmitriyMV
Copy link
Member

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.

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.

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 <dmitry.matrenichev@siderolabs.com>
@DmitriyMV
Copy link
Member Author

/m

@talos-bot talos-bot merged commit f4a4030 into siderolabs:v2 Jun 10, 2024
14 checks passed
@DmitriyMV DmitriyMV deleted the keep-alive branch June 10, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants