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

panic in Local.ymd_opt() on old dates for target i686-pc-windows-msvc #371

Closed
galich opened this issue Dec 12, 2019 · 7 comments
Closed
Labels

Comments

@galich
Copy link

galich commented Dec 12, 2019

This code:

[dependencies]
chrono = "0.4.10"
use chrono::{Local, TimeZone};

fn main() {
    println!("{:?}", Local.ymd_opt(1820, 1, 1));
}

results in panic inside time crate:

❯ cargo r
   Compiling ymdpanic v0.1.0 (C:\code\ymdpanic)
    Finished dev [unoptimized + debuginfo] target(s) in 0.44s
     Running `target\i686-pc-windows-msvc\debug\ymdpanic.exe`
thread 'main' panicked at 'attempt to subtract with overflow', C:\...\time-0.1.42\src\sys.rs:786:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: process didn't exit successfully: `target\i686-pc-windows-msvc\debug\ymdpanic.exe` (exit code: 101)
@quodlibetor
Copy link
Contributor

Could you re-run with RUST_BACKTRACE=1 and paste the backtrace? I don't have any way of running on i686-pc-windows-msvc

@quodlibetor quodlibetor changed the title panic in Local.ymd_opt() panic in Local.ymd_opt() on old dates for target i686-pc-windows-msvc Dec 27, 2019
@galich
Copy link
Author

galich commented Dec 27, 2019

sure, here it is:

    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target\i686-pc-windows-msvc\debug\ymdpanic.exe`
thread 'main' panicked at 'attempt to subtract with overflow', C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.42\src\sys.rs:786:22
stack backtrace:
   0: core::fmt::write
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libcore\fmt\mod.rs:1028
   1: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\io\mod.rs:1412
   2: std::sys_common::backtrace::_print
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\sys_common\backtrace.rs:65
   3: std::sys_common::backtrace::print
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\sys_common\backtrace.rs:50
   4: std::panicking::default_hook::{{closure}}
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:188
   5: std::panicking::default_hook
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:205
   6: std::panicking::rust_panic_with_hook
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:464
   7: std::panicking::continue_panic_fmt
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:373
   8: std::panicking::rust_begin_panic
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:302
   9: core::panicking::panic_fmt
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libcore\panicking.rs:139
  10: core::panicking::panic
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libcore\panicking.rs:70
  11: time::sys::inner::system_time_to_tm
             at C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.42\src\sys.rs:786
  12: time::sys::inner::time_to_local_tm
             at C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.42\src\sys.rs:828
  13: time::at
             at C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\time-0.1.42\src\lib.rs:419
  14: chrono::offset::local::{{impl}}::from_local_datetime
             at C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.10\src\offset\local.rs:142
  15: chrono::offset::local::{{impl}}::from_local_date
             at C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.10\src\offset\local.rs:134
  16: chrono::offset::TimeZone::ymd_opt<chrono::offset::local::Local>
             at C:\Users\serg\.cargo\registry\src\github.com-1ecc6299db9ec823\chrono-0.4.10\src\offset\mod.rs:235
  17: ymdpanic::main
             at .\src\main.rs:4
  18: std::rt::lang_start_internal::{{closure}}
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\rt.rs:48
  19: std::panicking::try::do_call<closure-0,i32>
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:287
  20: panic_unwind::__rust_maybe_catch_panic
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libpanic_unwind\lib.rs:78
  21: std::panicking::try
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panicking.rs:265
  22: std::panic::catch_unwind
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\panic.rs:396
  23: std::rt::lang_start_internal
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\/src\libstd\rt.rs:47
  24: std::rt::lang_start<()>
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14\src\libstd\rt.rs:61
  25: main
  26: BaseThreadInitThunk
  27: RtlGetAppContainerNamedObjectPath
  28: RtlGetAppContainerNamedObjectPath
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\i686-pc-windows-msvc\debug\ymdpanic.exe` (exit code: 101)```

@galich
Copy link
Author

galich commented Dec 27, 2019

FYI i've hacked this by changing this

        tm.tm_mon = (sys.wMonth - 1) as i32;
        tm.tm_year = (sys.wYear - 1900) as i32;

to this

        tm.tm_mon = (sys.wMonth as i32 - 1) as i32;
        tm.tm_year = (sys.wYear as i32 - 1900) as i32;

in sys.rs fn system_time_to_tm()

@quodlibetor
Copy link
Contributor

Ah, yeah that's too bad. I think this is enough motivation for me to move ahead with #286, which I've been meaning to do for awhile but have had some reservations.

@galich
Copy link
Author

galich commented Dec 27, 2019

time crate has been updated lately with less panics, perhaps try and update dependency on it in chrono?

@quodlibetor
Copy link
Contributor

quodlibetor commented Dec 27, 2019

Unfortunately the newest time crate relies on the absolute newest rust release, which breaks chronos backwards-compatibility policy, and the time 0.2 api is vastly different than 0.1.

@pitdicker
Copy link
Collaborator

This particular issue was fixed in #992. We still panic on years prior to 1601 however.

Because there are other open issues about that case I am going to close this one. See #651, #977 and #1150.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants