Several `Date` tests panic on Windows
Describe the bug Several tests related to the Date object panic on Windows
Panicking tests:
- test\annexB\built-ins\Date\prototype\setYear\year-number-absolute.js
thread 'main' panicked at 'TzSpecificLocalTimeToSystemTime failed with: The parameter is incorrect. (os error 87)', ...\chrono-0.4.19\src\sys\windows.rs:127:9
- test\annexB\built-ins\Date\prototype\setYear\year-number-relative.js
thread 'main' panicked at 'TzSpecificLocalTimeToSystemTime failed with: The parameter is incorrect. (os error 87)', ...\chrono-0.4.19\src\sys\windows.rs:127:9
- test\built-ins\Date\prototype\setFullYear\arg-year-to-number.js
thread 'main' panicked at 'TzSpecificLocalTimeToSystemTime failed with: The parameter is incorrect. (os error 87)', ...\chrono-0.4.19\src\sys\windows.rs:127:9
- test\built-ins\Date\prototype\toString\format.js
thread 'main' panicked at 'SystemTimeToFileTime failed with: The parameter is incorrect. (os error 87)', ...\chrono-0.4.19\src\sys\windows.rs:117:9
Build environment:
- OS: Windows
- Version: 10
- Target triple: x86_64-pc-windows-msvc
- Rustc version: rustc 1.56.0-nightly (ad02dc46b 2021-08-26)
Additional context
Investigating the origin of the panic I realized the first three tests call either setFullYear or setYear, so that's probably the origin of the panic.
I can confirm this still happens in the latest version.
The line of code that triggers the panic seems to be an unsafe call in chrono:
call!(TzSpecificLocalTimeToSystemTime(0 as *mut _, &mut sys_time, &mut utc));
Here's the full trace.
thread 'main' panicked at 'TzSpecificLocalTimeToSystemTime failed with: The parameter is incorrect. (os error 87)', C:\Users\henry\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.19\src\sys\windows.rs:127:9
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\std\src\panicking.rs:515
1: std::panicking::begin_panic_fmt
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\/library\std\src\panicking.rs:457
2: chrono::sys::inner::local_tm_to_time
at C:\Users\henry\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.19\src\sys\windows.rs:127
3: chrono::sys::Tm::to_timespec
at C:\Users\henry\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.19\src\sys.rs:122
4: chrono::offset::local::datetime_to_timespec
at C:\Users\henry\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.19\src\offset\local.rs:73
5: chrono::offset::local::impl$1::from_local_datetime
at C:\Users\henry\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.19\src\offset\local.rs:161
6: boa::builtins::date::impl$4::set_components::closure$2::closure$8
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\builtins\date\mod.rs:319
7: enum$<core::option::Option<chrono::naive::datetime::NaiveDateTime> >::and_then<chrono::naive::datetime::NaiveDateTime,chrono::naive::datetime::NaiveDateTime,boa::builtins::date::impl$4::set_components::closure$2::closure$8>
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\library\core\src\option.rs:1030
8: boa::builtins::date::impl$4::set_components::closure$2
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\builtins\date\mod.rs:313
9: enum$<core::option::Option<chrono::naive::datetime::NaiveDateTime> >::and_then<chrono::naive::datetime::NaiveDateTime,chrono::naive::datetime::NaiveDateTime,boa::builtins::date::impl$4::set_components::closure$2>
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\library\core\src\option.rs:1030
10: boa::builtins::date::Date::set_components
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\builtins\date\mod.rs:290
11: boa::builtins::date::Date::set_year
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\builtins\date\mod.rs:1221
12: boa::object::gcobject::JsObject::call_construct
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\object\gcobject.rs:321
13: boa::object::gcobject::JsObject::call
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\object\operations.rs:297
14: boa::context::Context::call
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\context.rs:397
15: boa::syntax::ast::node::call::impl$1::run
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\syntax\ast\node\call\mod.rs:113
16: boa::syntax::ast::node::impl$3::run
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\syntax\ast\node\mod.rs:316
17: boa::syntax::ast::node::statement_list::impl$1::run
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\syntax\ast\node\statement_list\mod.rs:152
18: boa::context::Context::eval<ref$<alloc::vec::Vec<u8,alloc::alloc::Global> > >
at C:\Users\henry\Documents\boa-master\boa-master\boa\src\context.rs:859
19: boa::main
at .\src\main.rs:163
20: core::ops::function::FnOnce::call_once<enum$<core::result::Result<tuple$<>,std::io::error::Error>, 0, 3, Err> (*)(),tuple$<> >
at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b\library\core\src\ops\function.rs:227
I'll continue to investigate.
@hle0 do you have any updates in the progress of this?
I believe the panics should be addressed with whichever new release of chrono with this pr. 😄 I'll run the suite locally when chrono is updated to confirm.
Maybe addressed by #3595? Needs confirmation.
Oh yeah, this should be addressed by that PR. chrono was the source of the panics, so removing it as a dependency would fix this.
Works now using the time crate.