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

feat(common): Improve native IO API #553

Open
clabby opened this issue Sep 23, 2024 · 0 comments
Open

feat(common): Improve native IO API #553

clabby opened this issue Sep 23, 2024 · 0 comments
Labels
A-common Area: kona-common crate K-feature Kind: feature

Comments

@clabby
Copy link
Collaborator

clabby commented Sep 23, 2024

Overview

Right now, the IO API for the native platform in kona-common is inherently unsafe. Though, because it is behind the BasicKernelInterface trait, the API is not actually marked as unsafe lexically.

The reason the API is currently unsafe is because of our use of raw file descriptors. The FileDescriptor enum for the FPVM target is constant, and it is also Clone + Copy. However, on the native platform, file descriptors cannot be safely cloned or copied without checking for potential issues with creating a second handle to the fd.

This has resulted in a hacky workaround, where we hold onto the raw file descriptor, expect the host process to keep them alive for long enough, and construct + forget the file for read and write ops. While this works, the API is very unclear, and this invisible requirement of having the host keep the file descriptors alive is a bit annoying.

Instead, we should treat the FileDescriptor enum as an owned type. Cloning or copying it should be a falliable operation, i.e. OwnedFd::try_clone.

This will help improve the API to expose a truly safe native IO API, and prevent us from having to leak the Files in NativeIO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-common Area: kona-common crate K-feature Kind: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant