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

Unsafe enum usage #66

Open
Koka opened this issue Feb 25, 2018 · 3 comments
Open

Unsafe enum usage #66

Koka opened this issue Feb 25, 2018 · 3 comments
Labels
bug upstream Issue related to upstream crate

Comments

@Koka
Copy link
Owner

Koka commented Feb 25, 2018

Passing mut enum across FFI boundaries causes UB in cases when ODBC driver returns value absent in enum. Details: https://users.rust-lang.org/t/undefined-behaviour-after-unsafe-enum-usage/15572

@Koka
Copy link
Owner Author

Koka commented Feb 25, 2018

NB: As a part of this fix we need to update odbc-sys to v 0.6.0 at least

@Koka
Copy link
Owner Author

Koka commented Feb 25, 2018

There is rust-lang/rust#44109 which is not implemented yet, but seems to be able to fix this problem

@scottmcm
Copy link

Note that [non_exhaustive] doesn't solve the unknown-discriminant-in-FFI case -- the crate that defines the enum is still allowed to exhaustively match on all the variants that exist (because it's the crate that owns the enum, so can update the match along with the new variant, if one is added) and thus it's still UB to put an unknown discriminant in an enum.

@Koka Koka added upstream Issue related to upstream crate and removed work-in-progress labels May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug upstream Issue related to upstream crate
Projects
None yet
Development

No branches or pull requests

2 participants