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

Enums in FFI types are unsafe #231

Closed
Stebalien opened this issue Jan 31, 2022 · 3 comments
Closed

Enums in FFI types are unsafe #231

Stebalien opened this issue Jan 31, 2022 · 3 comments

Comments

@Stebalien
Copy link
Member

It looks like we're using enums in FFI types in several places, but this is inherently unsafe as we can end up creating enums with arbitrary values and the rust type system will assume that this can't happen.

This can cause problems like:

  1. Code checking said enum value may be optimized away.
  2. If the enum has no zero variant but a zero is passed, rust may interpret Option<Enum> as None.
  3. Really, whatever the rust compiler wants to do.
@dignifiedquire
Copy link
Contributor

Asfaict all enums that are used are using repr(C) which should make them FFI safe, so I don't think these concerns apply.

@Stebalien
Copy link
Member Author

Stebalien commented Mar 19, 2022 via email

@Stebalien
Copy link
Member Author

Fixed.

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

No branches or pull requests

2 participants