-
Notifications
You must be signed in to change notification settings - Fork 346
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
localtime_r shim uses TZ variable from the host, not the interpreted program #3522
Comments
Thanks for looking into this, and sorry for causing this. I ran into this issue while testing and discussed with @oli-obk before, but I thought there is something wrong with my machine because it passed the CI and This is how the test looks like: fn test_tz_var_setting() {
use chrono::Local;
use std::env;
let key = "TZ";
env::set_var(key, "GMT");
assert_eq!(env::var(key), Ok("GMT".to_string()));
let offset_in_second = Local::now().offset().local_minus_utc();
// If the timezone is GMT, tm_gmtoff will be 0
let tm_gmtoff = offset_in_second;
assert_eq!(tm_gmtoff, 0);
env::remove_var(key);
assert!(env::var(key).is_err());
} In [dependencies]
# all dependencies (and their transitive ones) listed here can be used in `tests/`.
libc = "0.2"
num_cpus = "1.10.1"
tempfile = "3"
chrono = "0.4.37" This test still pass after I merged the latest update from master (commit |
That's using However, the shim uses |
I see, so |
No, it's impossible to change the host environment from the interpreted program. Mutating the environment is unsafe so it would be rather bad to let the interpreted program do that. ;) |
This makes sense, thanks! |
Use the interpreted program's TZ variable in localtime_r This requires a bit of wiring and a new dependency, but the tests should correctly pass now regardless of what the host's time zone is. Fixes rust-lang/miri#3522
Currently the test suite may fail to pass, unless you run it with
TZ=UTC ./miri test
. This is because thelocaltime_r
shim reads theTZ
variable from the host on this line:miri/src/shims/time.rs
Lines 139 to 140 in f26bd28
In other words, this test code is ineffective:
miri/tests/pass-dep/shims/libc-misc.rs
Lines 220 to 222 in f26bd28
I'm going to look into this.
cc @tiif @eduardosm
The text was updated successfully, but these errors were encountered: