-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Most sys enums are unsafe #277
Comments
So how about change bindgen to generate newtype enum? |
Ok, I'll open a new PR for that |
@Brooooooklyn This should be reopened. We use low level sys enums directly in napi calls again which can lead to them having an invalid state between versions of napi. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the bindgen docs for rustified enums:
This is problematic, as NAPI often adds to these enums across editions. This causes UB if, for example, an napi 3 module is loaded in an napi 6 context and calls typeof on a bigint, creating a rust enum with an invalid state.
This can be fixed by not using rust enums for these types and using constant values instead. Many
From
/Into
impls will have to be replaced withTryFrom/TryInto
, but these impls were unsafe anyways.I ran into this issue while working on #271. If you want, I can push fixes there or I can just make a new PR fixing this.
The text was updated successfully, but these errors were encountered: