benfred / py-spy

Sampling profiler for Python programs
MIT License
12.16k stars 401 forks source link

panic error message #552

Open Anto79-ops opened 1 year ago

Anto79-ops commented 1 year ago

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

BrainInSight commented 1 year ago

Same here

Jongy commented 1 year ago

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

Please attach:

Anto79-ops commented 1 year ago

@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

bdraco commented 1 year ago

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

Anto79-ops commented 1 year ago

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

Jongy commented 1 year ago

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)

BrainInSight commented 1 year ago

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

Anto79-ops commented 1 year ago

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

Anto79-ops commented 1 year ago

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 commented 1 year ago

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

Jongy commented 1 year ago

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.

Anto79-ops commented 1 year ago

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

pimw1 commented 1 year ago

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
Anto79-ops commented 1 year ago

any luck on a solution for this issue? thank you

JampireX commented 5 months ago

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