chrono
chrono copied to clipboard
Strange panic - Permission Denied/Operation not permitted
Hello. I have a problem with chrono on CI runner (Permission Denied), on local PC is ok.
Example code:
// let ts_option : Option<DateTime<Utc>> = ... (any code)
let ts_ns = ts_option.unwrap_or(Utc::now()).timestamp_nanos();
Log from CI:
4: thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" }', library/std/src/sys/unix/time.rs:371:62
4: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
4: thread '<unnamed>' panicked at 'panic in ffi function protocol_model_rs::bindings::ffi::Driver::decode, aborting.', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cxx-1.0.60/src/unwind.rs:37:9
4: stack backtrace:
4: 0: 0x56b8689a - std::backtrace_rs::backtrace::libunwind::trace::h6fd395343da42019
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
4: 1: 0x56b8689a - std::backtrace_rs::backtrace::trace_unsynchronized::h40e319688056ab33
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
4: 2: 0x56b8689a - std::sys_common::backtrace::_print_fmt::h0ebf85b7ed4ee037
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/sys_common/backtrace.rs:67:5
4: 3: 0x56b8689a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdd7a8ebec0f5aedd
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/sys_common/backtrace.rs:46:22
4: 4: 0x56bf9e63 - core::fmt::write::hf80721c1a36308b5
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/fmt/mod.rs:1078:17
4: 5: 0x56b7776e - std::io::Write::write_fmt::h89c362a239c199c3
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/io/mod.rs:1518:15
4: 6: 0x56b8b5b7 - std::sys_common::backtrace::_print::hf436473f0e54f76c
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/sys_common/backtrace.rs:49:5
4: 7: 0x56b8b5b7 - std::sys_common::backtrace::print::hef6291ee660532a3
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/sys_common/backtrace.rs:36:9
4: 8: 0x56b8b5b7 - std::panicking::default_hook::{{closure}}::h0d503946813983b4
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:208:50
4: 9: 0x56b8b251 - std::panicking::default_hook::hfdd131815c99e18f
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:227:9
4: 10: 0x56b8bf78 - std::panicking::rust_panic_with_hook::h1f1333429c3f05eb
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:593:17
4: 11: 0x56b8ba46 - std::panicking::begin_panic_handler::{{closure}}::h04412b7a66319a6d
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:499:13
4: 12: 0x56b86d5a - std::sys_common::backtrace::__rust_end_short_backtrace::h3dbb0e97bbc8cb8c
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/sys_common/backtrace.rs:141:18
4: 13: 0x56b8b9a1 - rust_begin_unwind
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/std/src/panicking.rs:495:5
4: 14: 0x56bf5c90 - core::panicking::panic_fmt::h4a91666b5adabb9c
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/panicking.rs:92:14
4: 15: 0x56ca6e85 - <cxx::unwind::Guard as core::ops::drop::Drop>::drop::h4696f766740c5adf
4: at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cxx-1.0.60/src/unwind.rs:37:9
4: 16: 0x56c202fe - core::ptr::drop_in_place::h3ce94194b0462ab9
4: at /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/ptr/mod.rs:175:1
4: 17: 0x567d65bc - cxx::unwind::prevent_unwind::h8c46083b145c799c
4: at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cxx-1.0.60/src/unwind.rs:28:1
4: 18: 0x567bf056 - rust_part$cxxbridge1$Driver$decode
4: at /usr/src/ecp/deps/ecp-ng/Model/protocol-model/protocol-model-rs/src/bindings.rs:600:66
4: 19: 0x567be6ec - _ZN9rust_part6Driver6decodeEjRKN4rust10cxxbridge13VecIhEE
4: at /usr/src/ecp/build/../deps/ecp-ng/Model/protocol-model/protocol-model-rs/protocol-model.cpp:965:37
4: 20: 0x567affa1 - _ZN11EtBusDriver6decodeEjN4rust10cxxbridge13VecIhEE
4: at /usr/src/ecp/build/../DDK/T5DDKC/ETBusDirect/etbus-driver/EtBusDriver.cpp:86:20
4: 21: 0x56632595 - ____C_A_T_C_H____T_E_S_T____0
4: at /usr/src/ecp/build/../DDK/T5DDKC/ETBusDirect/unit-tests/tests.cpp:336:22
4: 22: 0x5661c0a0 - _ZNK5Catch21TestInvokerAsFunction6invokeEv
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:14321:25
4: 23: 0x5661b370 - _ZNK5Catch8TestCase6invokeEv
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:14160:21
4: 24: 0x56615ed0 - _ZN5Catch10RunContext20invokeActiveTestCaseEv
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:13020:33
4: 25: 0x56615c5e - _ZN5Catch10RunContext14runCurrentTestERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:12993:37
4: 26: 0x56614a65 - _ZN5Catch10RunContext7runTestERKNS_8TestCaseE
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:12754:27
4: 27: 0x566174dc - execute
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:13347:62
4: 28: 0x566187e5 - _ZN5Catch7Session11runInternalEv
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:13553:47
4: 29: 0x5661851f - _ZN5Catch7Session3runEv
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:13509:35
4: 30: 0x5665f8b3 - _ZN5Catch7Session3runIcEEiiPKPKT_
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:13231:33
4: 31: 0x5662edf8 - main
4: at /root/.conan/data/catch2/2.13.7/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/catch2/catch.hpp:17526:32
4: 32: 0x29c3ffd6 - __libc_start_main
4: 33: 0x566052d1 - _start
4: 34: 0x0 - <unknown>
4: thread panicked while panicking. aborting.
https://doc.rust-lang.org/beta/src/std/sys/unix/time.rs.html#370 https://linux.die.net/man/3/clock_gettime
Probably access to the high accuracy timer inside container is not allowed.
I don't think there is anything we can do here. We just use std::time::SystemTime::now().
The standard library checks the return value of clock_gettime(), but panics on error.
Maybe this should be opened as an issue against the standard library? Although I don't know what they should do when the clock is unavailable.
Opened https://github.com/rust-lang/rust/issues/115482.
Although I don't know what they should do when the clock is unavailable.
It seems entirely reasonable to also provide an approach that does not panic (returns None instead). Let the user decide how to handle the situation.
We can even choose to do something different from the standard library. But for now we don't even know when it happens precisely, and if it is worth caring :smile:.
Closing because we don't have the information to reproduce, have reported it upstream (the standard library), and have https://github.com/chronotope/chrono/issues/1250 to discuss if we want to expose the platform capabilities in some way.