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

dynamic_lib misuses task::atomically in the check_for_errors_in implementations #8156

Closed
mstewartgallus opened this issue Jul 31, 2013 · 0 comments · Fixed by #9713
Closed

Comments

@mstewartgallus
Copy link
Contributor

Issue #8140 brought to my attention that some code in the dynamic library implementation was incorrect. After chatting to @bblum on IRC, I figured out my mistake in creating the implementation. Apparently the function task::atomically only asserts that no context switching occurs, and does not in fact prevent it. A corrected pair of check_for_errors_in functions should replace the use of task::atomically with some locking mechanism to prevent threads from stepping on each others use of errno (or the equivalent Win32 error variable.) Maybe this locking mechanism for safely accessing the error variable should also be exposed separately in Rust's OS interaction facilities.

bors added a commit that referenced this issue Oct 5, 2013
The root issue is that dlerror isn't reentrant or even thread safe.

The solution implemented here is to make a yielding spin lock over an
AtomicFlag. This is pretty hacky, but the best we can do at this point.
As far as I can tell, it isn't possible to create a global mutex without
having to initialize it in a single threaded context.

The Windows code isn't affected since errno is thread-local on Windows
and it's running in an atomically block to ensure there isn't a green
thread context switch.

Closes #8156
@bors bors closed this as completed in 1d19ad9 Oct 5, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 6, 2022
[`needless_return`] Recursively remove unneeded semicolons

fix rust-lang#8336,
fix rust-lang#8156,
fix rust-lang/rust-clippy#7358,
fix rust-lang#9192,
fix rust-lang/rust-clippy#9503

changelog: [`needless_return`] Recursively remove unneeded semicolons

For now the suggestion about removing the semicolons are hidden because they would be very noisy and should be obvious if the user wants to apply the lint manually instead of using `--fix`. This could be an issue for beginner, but haven't found better way to display it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant