Macchina-CLI / macchina

A system information frontend with an emphasis on performance.
https://crates.io/crates/macchina
MIT License
1.24k stars 47 forks source link

[BUG] Crashes on FreeBSD 13 #267

Closed yonas closed 1 year ago

yonas commented 1 year ago

Describe the bug Macchina crashes on FreeBSD 13.

To Reproduce Steps to reproduce the behavior:

  1. Run cargo install macchina
  2. Run macchina

Expected behavior It should display system information.

Screenshots

$ RUST_BACKTRACE=full macchina
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error(Utf8Error { valid_up_to: 48, error_len: Some(1) })', /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/libmacchina-6.3.1/src/freebsd/mod.rs:244:14
stack backtrace:
   0:     0x3b064fc4c4d1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf9bca0a54f465bd9
   1:     0x3b064fbf7d0e - core::fmt::write::hdf9e1b7bc0c7ef23
   2:     0x3b064fc28c44 - std::io::Write::write_fmt::h6e00616d8cf5d394
   3:     0x3b064fc37186 - std::panicking::default_hook::{{closure}}::ha5a1e37665f439d8
   4:     0x3b064fc37ae4 - std::panicking::rust_panic_with_hook::h184324b56212ec2b
   5:     0x3b064fc4c862 - std::panicking::begin_panic_handler::{{closure}}::hdd7dccc960a25e4f
   6:     0x3b064fc4c7d6 - std::sys_common::backtrace::__rust_end_short_backtrace::h1fb3000d64dd03f0
   7:     0x3b064fc374c2 - rust_begin_unwind
   8:     0x3b064fbf9e12 - core::panicking::panic_fmt::hc3aba48bba555f86
   9:     0x3b064fbfad22 - core::result::unwrap_failed::hb64f9d366cb13a63
  10:     0x3b064fb7bc3c - macchina::data::get_all_readouts::heeef78197dbc036f
  11:     0x3b064fb8454a - macchina::main::h38699e8f6cd6d7fc
  12:     0x3b064fb530f3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc47aa0a27d9d3a07
  13:     0x3b064fb534a1 - std::rt::lang_start::{{closure}}::h6e1fe9ba24be0494
  14:     0x3b064fba55a7 - main

macchina --doctor output

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error(Utf8Error { valid_up_to: 48, error_len: Some(1) })', /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/libmacchina-6.3.1/src/freebsd/mod.rs:244:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

System Information You don't have to provide this information if you're not comfortable doing so, but it'll help us solve the issue a lot faster.

grtcdr commented 1 year ago

I'll try and fix this nasty unwrap(), I think the reason it's panicking is because a key piece of information is missing from your machine, i.e. hw.model. Does sysctl -a hw.model not work?

yonas commented 1 year ago

Thanks. Yes, it works. Here is the output:

$ sysctl -a hw.model
hw.model: Intel Core i7 9xx (Nehalem Core i7, IBRS update)
grtcdr commented 1 year ago

I made a mistake when I was analyzing the source code and stack trace. The unwrap() fails because it found some invalid byte in the string value of model_ctl (your processor's model).

I don't know why this happened in the first place, but we could try and mitigate this.

yonas commented 1 year ago

I think it's related to qemu / kvm. I remember neofetch having an issue displaying the CPU a while ago.

grtcdr commented 1 year ago

Oh, I see.

I've removed the numerous unwrap() calls in this commit, but I'm afraid this will not solve the issue.

yonas commented 1 year ago

There seem to be some compiling errors with https://github.com/Macchina-CLI/libmacchina/commit/aa168fdfacda6df957f7ef54f0797c86b1e4932f.

Gobidev commented 1 year ago

As of ee21fcd69b4106bdd2156315ff64365c0ad15f14, I don't have any issues running macchina on FreeBSD 13.1

yonas commented 1 year ago

As of ee21fcd, I don't have any issues running macchina on FreeBSD 13.1

Same for me. Closing as fixed.