-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
global little-locks (change_dir_lock, global_args_lock) are sloppy and wrong #8140
Comments
(at least they don't have the error where the lock function takes one of the locks but the unlock drops the other. that would be really embarrassing. (but they could!)) |
@bblum Yeah, I'm sorry. I should probable fix that. Here's why I used |
This will require creating platform-specific bindings to mutexes so that we can declare them statically. |
@brson: My idea for it was something like this, sort of like the trick that #7748 would use.
Doesn't need any more platform-specific stuff than the existing |
Closing now that this has been fixed. We now have a lazily initialized static mutex type which serves to be a small short-lived (and properly scoped) lock for sections like this. Right now this does not leverage the |
rust_builtin.cpp
has some builtins for accessing the "change_dir_lock" and the "global_args_lock". As evidenced by the fact that both of them accidentally use the same lock(!), this approach is prone to error. It would be better if the associated places in rust code could just useunstable::sync::LittleLock
directly.For extra bonus points, we should be able to have unsafe mutable global LittleLocks that are lazily initialized in
LittleLock::lock()
. This would allowatomically
to become totally private tounstable::sync
, as #7872 really wants.(But, I can't figure out what's going on with the use of
atomically
instead ofLittleLock
inunstable::dynamic_lib::check_for_errors_in
. @sstewartgallus, git blame points to you -- can you shed light on this?)The text was updated successfully, but these errors were encountered: