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

gmtime and localtime aren't thread-safe so using them is unsound #12693

Closed
thestinger opened this issue Mar 4, 2014 · 5 comments
Closed

gmtime and localtime aren't thread-safe so using them is unsound #12693

thestinger opened this issue Mar 4, 2014 · 5 comments

Comments

@thestinger
Copy link
Contributor

It's unclear if these wrappers in rust_builtin.c are actually used anywhere, but the code should be removed either way.

@alexcrichton
Copy link
Member

This is only the case for mingw32.

@lifthrasiir
Copy link
Contributor

cc #10480. We really want to decouple the datetime routines from the global states except when it is absolutely required (retrieving the current timezone, for example).

@deokjinkim
Copy link

As I know, gmtime and localtime are thread-safe on Windows(Microsoft) because such functions use static output area per thread.
And for other platform, gmtime_r and localtime_r are thread-safe version.
So I think current usage of above function is not problem.
Do you mean timezone variable(TZ) for localtime may cause thread-safety issue?

@klutzy
Copy link
Contributor

klutzy commented Jan 14, 2015

The relevant code is rt/rust_builtin.c. libtime used them via rust_{gm,local}time but libtime has been moved out of tree.
cc #20861

@klutzy
Copy link
Contributor

klutzy commented Feb 3, 2015

#21391 removed time wrappers. Fixed!

flip1995 pushed a commit to flip1995/rust that referenced this issue May 2, 2024
…ass_by_ref_mut, r=Manishearth

Emit the `needless_pass_by_ref_mut` lint on `self` arguments as well

Fixes rust-lang/rust-clippy#12589.
Fixes rust-lang/rust-clippy#9591.

The first commit fixes a bug I uncovered while working on this: sometimes, the mutable borrow "event" happens before the alias one, which makes some argument detected as not used mutably even if they are. The fix was simply to fill the map with the aliases afterwards.

The second commit removes the restriction to not run `self` argument for the `needless_pass_by_ref_mut` lint.

changelog: emit the `needless_pass_by_ref_mut` lint on `self` arguments as well

r? `@Manishearth`
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

No branches or pull requests

5 participants