coreutils
coreutils copied to clipboard
`touch`: Intermittent error `'Error The system's UTC offset could not be determined retrieving the OffsetDateTime::now_local'`
Can be seen in https://github.com/uutils/coreutils/actions/runs/3817216997/jobs/6493335664
---- test_touch::test_touch_leap_second stdout ----
current_directory_resolved:
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils touch -t 197001010000.60 test_touch_leap_sec
---- test_touch::test_touch_leap_second stderr ----
thread 'main' panicked at 'Error The system's UTC offset could not be determined retrieving the OffsetDateTime::now_local', tests/by-util/test_touch.rs:55:13
stack backtrace:
0: rust_begin_unwind
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/core/src/panicking.rs:64:14
2: tests::test_touch::str_to_filetime
at ./tests/by-util/test_touch.rs:55:13
3: tests::test_touch::test_touch_leap_second
at ./tests/by-util/test_touch.rs:796:17
4: tests::test_touch::test_touch_leap_second::{{closure}}
at ./tests/by-util/test_touch.rs:786:29
5: core::ops::function::FnOnce::call_once
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/core/src/ops/function.rs:250:5
6: core::ops::function::FnOnce::call_once
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once{{vtable.shim}}
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/core/src/ops/function.rs:250:5
8: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/alloc/src/boxed.rs:1988:9
9: test::run_test_in_spawned_subprocess
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/test/src/lib.rs:793:27
10: test::test_main_static_abort
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/test/src/lib.rs:186:9
11: tests::main
at ./tests/tests.rs:1:1
12: core::ops::function::FnOnce::call_once
at /rustc/574b64a97f52162f965bc201e47f0af8279ca65d/library/core/src/ops/function.rs:250:5
Same intermittent error with test_touch::test_touch_mtime_dst_succeeds
---- test_touch::test_touch_mtime_dst_succeeds stdout ----
current_directory_resolved:
run: /home/runner/work/coreutils/coreutils/target/debug/coreutils touch -m -t 202103140300 test_touch_set_mtime_dst_succeeds
---- test_touch::test_touch_mtime_dst_succeeds stderr ----
thread 'main' panicked at 'Error The system's UTC offset could not be determined retrieving the OffsetDateTime::now_local', tests/by-util/test_touch.rs:55:13
stack backtrace:
0: rust_begin_unwind
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/panicking.rs:575:5
1: core::panicking::panic_fmt
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/panicking.rs:64:14
2: tests::test_touch::str_to_filetime
at ./tests/by-util/test_touch.rs:55:13
3: tests::test_touch::test_touch_mtime_dst_succeeds
at ./tests/by-util/test_touch.rs:628:23
4: tests::test_touch::test_touch_mtime_dst_succeeds::{{closure}}
at ./tests/by-util/test_touch.rs:618:36
5: core::ops::function::FnOnce::call_once
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ops/function.rs:250:5
6: core::ops::function::FnOnce::call_once
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ops/function.rs:250:5
7: core::ops::function::FnOnce::call_once{{vtable.shim}}
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ops/function.rs:250:5
8: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/alloc/src/boxed.rs:1988:9
9: test::run_test_in_spawned_subprocess
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/test/src/lib.rs:793:27
10: test::test_main_static_abort
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/test/src/lib.rs:186:9
11: tests::main
at ./tests/tests.rs:1:1
12: core::ops::function::FnOnce::call_once
at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
test_touch::test_touch_mtime_dst_succeeds
Looking at https://github.com/uutils/coreutils/issues/1592, I think touch should almost never have to look up the time. Instead, it should just access the files and let the kernel set the filetimes based on that access. We might be able to fix 2 issues at the same time here :)
I think this issue is related to https://github.com/time-rs/time/issues/380#issuecomment-1336212898
Basically in order to mitigate https://github.com/time-rs/time/issues/293, the time crate will return an error from time::OffsetDateTime::now_local() if there are multiple threads in the process at the time it is called on some OSes (notably, including linux). So, if the test runner has spawned multiple threads when the str_to_filetime function is called, it will panic.
Some ways this could potentially be fixed:
- Run these specific tests with
--test-threads=1 - Rewrite the tests to not need the local offset somehow
- Switch to using
chronofor this (which now has it's own pure-rust implementation for getting the timezone) - get the offset using a separate process
- compile the tests with the
unsound_local_offsetcfg set to true. I'm not sure if that is safe to do in a test environment.
This can happen with a lot of the touch tests. In https://github.com/uutils/coreutils/actions/runs/4426675036/jobs/7763252843. It's these:
test_touch::test_touch_leap_second
test_touch::test_touch_mtime_dst_succeeds
test_touch::test_touch_set_both
test_touch::test_touch_set_cymdhm_time
test_touch::test_touch_set_cymdhms_time
test_touch::test_touch_set_date
test_touch::test_touch_set_date2
test_touch::test_touch_set_mdhm_time
test_touch::test_touch_set_mdhms_time
test_touch::test_touch_set_only_atime
test_touch::test_touch_set_only_mtime