py-spy icon indicating copy to clipboard operation
py-spy copied to clipboard

panic error message

Open Anto79-ops opened this issue 2 years ago • 15 comments

Hello all,

Not sure if this is an issue or usage problem, so I wanted to reach out.

I'm trying to install and run py-spy on Home Assistant OS in the container by these commands from these instructions:

wget https://github.com/benfred/py-spy/releases/download/v0.3.12/py_spy-0.3.12-py2.py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
unzip py_spy-0.3.12-py2.py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

However, when I to run the py-spy on the PID of interest, i get these errors:

bash-5.1# cd py_spy-0.3.14.data
bash-5.1# cd scripts
bash-5.1# ./py-spy top --pid 61
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-maps-0.2.1/src/linux_maps.rs:81:65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: receiving on a closed channel
bash-5.1# ./py-spy top --pid 60
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-maps-0.2.1/src/linux_maps.rs:81:65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: receiving on a closed channel

Does anyone know what these means and how to solve the problem?

thank you

Anto79-ops avatar Feb 13 '23 16:02 Anto79-ops

Same here

BrainInSight avatar Mar 03 '23 15:03 BrainInSight

The problem is with parsing the process maps - probably of the PID you're trying to profile.

Please attach:

  • /proc/pid/maps outputs for the process you tried to profile / top, i.e cat /proc/60/maps
  • Please run with RUST_BACKTRACE=1 so we get full stack trace (so we know which field specifically failed to parse). From the line number I suppose it's range_start: usize::from_str_radix(range_start, 16).unwrap() but let's be sure.

Jongy avatar Mar 05 '23 10:03 Jongy

@Jongy thank you very much for these instructions.

just a couple mentions

  1. when I tried cat /proc/66/maps (PID is now 66), there is a quite a bit of lines coming out, not sure how write to file so that I can share that with you
  2. how do I exactly do this? when I type that, it just gives me the same message
bash-5.1# ./py-spy top --pid 66 RUST_BACKTRACE=1
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-maps-0.2.1/src/linux_maps.rs:81:65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: receiving on a closed channel
bash-5.1#

thanks for your time

Anto79-ops avatar Mar 05 '23 15:03 Anto79-ops

RUST_BACKTRACE=1 ./py-spy top --pid 66

bdraco avatar Mar 06 '23 06:03 bdraco

thanks @bdraco!

here's what that command outputs (word wrapping might be weird so you'll have to scroll all the way right) :

py-spy
bash-5.1# RUST_BACKTRACE=1 ./py-spy top --pid 67

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Par                                                      seIntError { kind: PosOverflow }', /root/.cargo/registry/src/github.com-1ecc6299                                                      db9ec823/proc-maps-0.2.1/src/linux_maps.rs:81:65
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/                                                      panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src                                                      /panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src                                                      /result.rs:1785:5
   3: proc_maps::linux_maps::get_process_maps
   4: py_spy::python_spy::PythonSpy::new
   5: py_spy::python_spy::PythonSpy::retry_new
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose bac                                                      ktrace.
Error: receiving on a closed channel

and just to confirm the PID of interest is now 67

image

Anto79-ops avatar Mar 06 '23 06:03 Anto79-ops

Thanks @Anto79-ops . Getting the contents of /proc/pid/maps will help as the some "protocol" between the file and the parser is broken and having the raw contents will help understanding exactly which.

when I tried cat /proc/66/maps (PID is now 66), there is a quite a bit of lines coming out, not sure how write to file so that I can share that with you

It can be quite long indeed (depending on the amount of libraries your process has loaded), but since any of those lines can be the problematic line, we'll need the full one. You can attach it as a message in GitHub (copy the file aside, then drag and drop it to the textbox)

Jongy avatar Mar 06 '23 08:03 Jongy

Hi,

as mentioned above I have the same problems (and the same output for RUST_BACKTRACE=1 ./py-spy top --pid 66 as above). Here is the content of my /proc/66/maps.

maps.txt

BrainInSight avatar Mar 06 '23 09:03 BrainInSight

@BrainInSight could you please tell me how you wrote your maps to a file? Thanks

Anto79-ops avatar Mar 06 '23 13:03 Anto79-ops

ok, was able to get the maps file thanks @Jongy

maps.txt

and just to be consistent, here's the RUST_BACKTRACE for the same session

bash-5.1# RUST_BACKTRACE=1 ./py-spy top --pid 68
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-maps-0.2.1/src/linux_maps.rs:81:65
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
   3: proc_maps::linux_maps::get_process_maps
   4: py_spy::python_spy::PythonSpy::new
   5: py_spy::python_spy::PythonSpy::retry_new
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Error: receiving on a closed channel
bash-5.1#

image

Anto79-ops avatar Mar 06 '23 23:03 Anto79-ops

Hi @Jongy wondering if you had a chance to look the logs, and perhaps see a resolution. Thanks for your help and time.

Anto79-ops avatar Mar 13 '23 04:03 Anto79-ops

Hi @Anto79-ops haven't had the chance yet, I'll update once I do :)

I did try meanwhile to run proc-maps crate on v0.2.1 (used by py-spy) and on master with your file from here and @BrainInSight 's file from here. Both manage to parse correctly so I might be doing something wrong :/ will continue testing it thoroughly once I find the time.

Jongy avatar Mar 23 '23 01:03 Jongy

Thank you @Jongy anytime you put to this issue is greatly appreciated.

Anto79-ops avatar Mar 23 '23 04:03 Anto79-ops

Hi, i'm facing the same issue. See below the ouput of backtrace=1 . I hope this might help to find the issue.

bash-5.1# RUST_BACKTRACE=1 ./py-spy top --pid 66
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-maps-0.2.1/src/linux_maps.rs:81:65
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
   3: proc_maps::linux_maps::get_process_maps
   4: py_spy::python_spy::PythonSpy::new
   5: py_spy::python_spy::PythonSpy::retry_new

pimw1 avatar Apr 03 '23 17:04 pimw1

any luck on a solution for this issue? thank you

Anto79-ops avatar May 17 '23 17:05 Anto79-ops

I have the same backtrace. Attaching my maps. maps.txt

JampireX avatar Jan 09 '24 16:01 JampireX