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

touch: Intermittent error 'Error The system's UTC offset could not be determined retrieving the OffsetDateTime::now_local' #4253

Open
Joining7943 opened this issue Jan 1, 2023 · 4 comments
Labels

Comments

@Joining7943
Copy link
Contributor

Can be seen in https:/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
@Joining7943
Copy link
Contributor Author

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

@tertsdiepraam
Copy link
Member

Looking at #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 :)

@tmccombs
Copy link
Contributor

I think this issue is related to time-rs/time#380 (comment)

Basically in order to mitigate time-rs/time#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:

  1. Run these specific tests with --test-threads=1
  2. Rewrite the tests to not need the local offset somehow
  3. Switch to using chrono for this (which now has it's own pure-rust implementation for getting the timezone)
  4. get the offset using a separate process
  5. compile the tests with the unsound_local_offset cfg set to true. I'm not sure if that is safe to do in a test environment.

@tertsdiepraam
Copy link
Member

This can happen with a lot of the touch tests. In https:/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

4 participants