-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Remove unsafe #7667
Remove unsafe #7667
Conversation
2296320
to
b5b8bee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean indeed, I don't suppose you have a test that would demonstrate how to get the sigsegv?
The sigsegv was caused by stack overflow, (I had raised the stack limit with ulimit -s but that didnt help but wolfgang pointed me to env RUST_MIN_STACK) while investigating the memory I stumbled upon this |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
* remove unsafe * add comment
Description
Over the weekend I investigated some SIGSEGV I experienced and was looking at unsafe code in our code base as possible culprits. I encountered this which I initially thought must be wrong (Option<Box> is type punned as an usize). It turns out that absolute compiler magic makes Option<Box> the same size as usize, but I feel that kind of code is ridiculous.
The problem is that one cannot use [None, NB_BUCKETS] as Bucket == Option<Box> is non-copyable, however one can simply work around that by using cont INIT: Bucket = None, and use INIT as initialization value.
This seems cleaner