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

sys panics #10155

Closed
mksinicus opened this issue Aug 30, 2023 · 4 comments · Fixed by #12846
Closed

sys panics #10155

mksinicus opened this issue Aug 30, 2023 · 4 comments · Fixed by #12846
Labels
🐛 bug Something isn't working panic
Milestone

Comments

@mksinicus
Copy link

Describe the bug

Running sys command crashed my Nushell 0.84.0, both in REPL and when run as a script

How to reproduce

I started with no config file to ensure it wasn't my config causing it:

> RUST_BACKTRACE=1 nu -n -c 'sys'
thread 'main' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:584:31
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_display
   3: core::panicking::panic_str
   4: core::option::expect_failed
   5: <std::time::SystemTime as core::ops::arith::Add<core::time::Duration>>::add
   6: <nu_command::system::sys::SysResult as nu_protocol::value::lazy_record::LazyRecord>::get_column_value
   7: nu_protocol::value::lazy_record::LazyRecord::collect
   8: nu_command::viewers::table::handle_table_command
   9: <nu_command::viewers::table::Table as nu_protocol::engine::command::Command>::run
  10: nu_cli::eval_file::print_table_or_error
  11: nu_cli::eval_cmds::evaluate_commands
  12: nu::run::run_commands
  13: nu::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

With RUST_BACKTRACE=full:

> RUST_BACKTRACE=full nu -n -c 'sys'
thread 'main' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:584:31
stack backtrace:
   0:     0x55cf57bfbade - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h254ba81a1e20fed0
   1:     0x55cf5634a81e - core::fmt::write::h232ccd94259bfe24
   2:     0x55cf57bf48b5 - std::io::Write::write_fmt::h963cfaecfdd596f7
   3:     0x55cf57bfb8b5 - std::sys_common::backtrace::print::h55ab07cec21aacd5
   4:     0x55cf57bfd65f - std::panicking::default_hook::{{closure}}::hc10df65206eee69e
   5:     0x55cf57bfd3d4 - std::panicking::default_hook::hdd684731d8d78925
   6:     0x55cf57bfdd01 - std::panicking::rust_panic_with_hook::h58681788b2d08dc0
   7:     0x55cf57bfda96 - std::panicking::begin_panic_handler::{{closure}}::he6d9da406579493c
   8:     0x55cf57bfc00c - std::sys_common::backtrace::__rust_end_short_backtrace::h5b1f3b233c047d47
   9:     0x55cf57bfd7d2 - rust_begin_unwind
  10:     0x55cf55f19573 - core::panicking::panic_fmt::hea602a2467b5109d
  11:     0x55cf56347cb1 - core::panicking::panic_display::h004b21ebd7b3fdaf
  12:     0x55cf56347c5b - core::panicking::panic_str::h1be31f1d04ef75ea
  13:     0x55cf55f19536 - core::option::expect_failed::ha787446d279c56c7
  14:     0x55cf57bfb777 - <std::time::SystemTime as core::ops::arith::Add<core::time::Duration>>::add::h1bade89a1e1de4c5
  15:     0x55cf56967c5b - <nu_command::system::sys::SysResult as nu_protocol::value::lazy_record::LazyRecord>::get_column_value::h8d01acf26c2b5c73
  16:     0x55cf56936477 - nu_protocol::value::lazy_record::LazyRecord::collect::h927b98d2b6eb3706
  17:     0x55cf56795d7f - nu_command::viewers::table::handle_table_command::hca7514e6cad81505
  18:     0x55cf567948c0 - <nu_command::viewers::table::Table as nu_protocol::engine::command::Command>::run::h0ec2966a12a3786a
  19:     0x55cf5643cd59 - nu_cli::eval_file::print_table_or_error::h485160c984c2a886
  20:     0x55cf5644f60a - nu_cli::eval_cmds::evaluate_commands::h266557235d4a57e5
  21:     0x55cf56412da3 - nu::run::run_commands::h62732646b065e689
  22:     0x55cf5642257b - nu::main::h5dc23537ee251a4c
  23:     0x55cf5640f8e8 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd7190ed1a167e12e
  24:     0x55cf5642368a - std::rt::lang_start::{{closure}}::h5deffa3302803be5
  25:     0x55cf57bec53c - std::rt::lang_start_internal::h7868f0ffe3ad1ec2
  26:     0x55cf56423395 - main
  27:     0x7fd553029d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  28:     0x7fd553029e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  29:     0x55cf55f8b185 - _start
  30:                0x0 - <unknown>

My installation: cargo install nu --features=extra,dataframe --locked

Expected behavior

Shouldn't crash...

Screenshots

No response

Configuration

key value
version 0.84.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.68.1 (8460ca823 2023-03-20)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.68.1 (115f34552 2023-02-26)
build_time 2023-08-30 23:28:59 +08:00
build_rust_channel release
allocator standard
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins from eml, from ics, from ini, from vcf, query, query json, query web, query xml

Additional context

No response

@mksinicus mksinicus added the needs-triage An issue that hasn't had any proper look label Aug 30, 2023
@fdncred
Copy link
Collaborator

fdncred commented Aug 30, 2023

I can't reproduce on the latest main branch in Windows or Ubuntu.

 RUST_BACKTRACE=1 nu -n -c 'sys'
╭───────┬───────────────────╮
 host   {record 8 fields} 
 cpu    [table 12 rows]   
 disks  [table 14 rows]   
 mem    {record 7 fields} 
 temp   [list 0 items]    
 net    [table 3 rows]    
╰───────┴───────────────────╯

@mksinicus
Copy link
Author

Strange... I use Kubuntu 22.04.

I have a guess, since the panic message involved "duration": I've experienced incorrect system datetime after waking from sleep, and had to reset it after I connected to Internet. Something remained erroneous, for example, my uptime shows

> uptime
 00:11:58 up -24855 days, -3:-14,  3 users,  load average: 0.74, 0.99, 1.30

I will try again after rebooting.

@mksinicus
Copy link
Author

Rebooting solved the problem... Closing for now.

@kubouch
Copy link
Contributor

kubouch commented Aug 30, 2023

I think in this case, we should harden the sys command code such that it doesn't panic if there is an invalid date/duration. I'll reopen for this reason.

@kubouch kubouch reopened this Aug 30, 2023
@kubouch kubouch added 🐛 bug Something isn't working panic and removed needs-triage An issue that hasn't had any proper look labels Aug 30, 2023
WindSoilder pushed a commit that referenced this issue May 15, 2024
# Description
This should fix #10155 where the `sys` command can panic due to date
math in certain cases / on certain systems.

# User-Facing Changes
The `boot_time` column now has a date value instead of a formatted date
string. This is technically a breaking change.
@hustcer hustcer added this to the v0.94.0 milestone May 15, 2024
FilipAndersson245 pushed a commit to FilipAndersson245/nushell that referenced this issue May 18, 2024
# Description
This should fix nushell#10155 where the `sys` command can panic due to date
math in certain cases / on certain systems.

# User-Facing Changes
The `boot_time` column now has a date value instead of a formatted date
string. This is technically a breaking change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants