-
-
Notifications
You must be signed in to change notification settings - Fork 434
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
Fallback to the global allocator when the TLS var has been deinitialized. #154
Comments
There are no stable methods to do this yet, see rust-lang/rust#27716. With 'global RNG state you probably mean |
Question: why are you using Besides, we don't have a "global RNG state". |
I suppose it has become a good time to work on this now that Replacing Or is using I suppose I can see one use case: filling memory or files with random bits before closing/deallocation (although I don't see the advantage over zeroing). Should we fix this? |
I'm not really sure that we should. But I suggest we leave this issue open. It's not a bug though, more a feature. |
This is a year old now, and doesn't appear to have any other interested parties. Besides which, usage of a random number generator in a destructor is probably a poor design, given that one cannot guarantee destructors run anyway (e.g. if you wanted to write over password memory, better to do it before destruction). So, lets close. |
Currently you (sometimes) get a panick if you use
rand::random()
in a TLS dtor. This is because the RNG state TLS var can have been deinitialized and thus unavailable. Ideally,rand
should check if the TLS var is available (https://doc.rust-lang.org/nightly/std/thread/struct.LocalKey.html#method.state), and if not, fallback to the global RNG state.The text was updated successfully, but these errors were encountered: