Open
Description
Describe the bug
The Pyroscope Python client stops reporting updates after a random period of time. When the reporting stops a Rust error appears in the console. This seems to be related to an issue in py-spy ostensibly related to Python 3.12+.
When the environment variable RUST_BACKTRACE=full
is set, the error message is as follows:
thread '<unnamed>' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py-spy-0.4.0/src/python_interpreters.rs:251:20:
index out of bounds: the len is 8 but the index is 8
stack backtrace:
0: 0x7fd8b92f1ce9 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h304520fd6a30aa07
1: 0x7fd8b904322b - core::fmt::write::hf5713710ce10ff22
2: 0x7fd8b92c4f12 - std::io::Write::write_fmt::hda708db57927dacf
3: 0x7fd8b92f2ee8 - std::panicking::default_hook::{{closure}}::he1ad87607d0c11c5
4: 0x7fd8b92f3d9d - std::panicking::rust_panic_with_hook::had2118629c312a4a
5: 0x7fd8b92f3885 - std::panicking::begin_panic_handler::{{closure}}::h7fa5985d111bafa2
6: 0x7fd8b92f37e9 - std::sys::backtrace::__rust_end_short_backtrace::h704d151dbefa09c5
7: 0x7fd8b92f37d4 - rust_begin_unwind
8: 0x7fd8b8fed8f2 - core::panicking::panic_fmt::h3eea515d05f7a35e
9: 0x7fd8b8fed8b6 - core::panicking::panic_bounds_check::hab02a8df06d3a143
10: 0x7fd8b90c8f71 - <py_spy::python_bindings::v3_13_0::PyCodeObject as py_spy::python_interpreters::CodeObject>::get_line_number::ha0acd799f57899c2
11: 0x7fd8b90e9d9a - py_spy::stack_trace::get_stack_trace::he20cabbdb1e0a350
12: 0x7fd8b90d5c5a - py_spy::python_spy::PythonSpy::get_stack_traces::h77c955cf98714a62
13: 0x7fd8b911a648 - std::sys::backtrace::__rust_begin_short_backtrace::ha57db72ab93bffdd
14: 0x7fd8b911a1f3 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0d7bdac7f65621fa
15: 0x7fd8b92f4feb - std::sys::pal::unix::thread::Thread::new::thread_start::hcdbd1049068002f4
16: 0x7fd90b0b9ac3 - <unknown>
17: 0x7fd90b14aa04 - clone
18: 0x0 - <unknown>
thread '<unnamed>' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/py-spy-0.4.0/src/sampler.rs:264:22:
called `Result::unwrap()` on an `Err` value: Any { .. }
stack backtrace:
0: 0x7fd8b92f1ce9 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h304520fd6a30aa07
1: 0x7fd8b904322b - core::fmt::write::hf5713710ce10ff22
2: 0x7fd8b92c4f12 - std::io::Write::write_fmt::hda708db57927dacf
3: 0x7fd8b92f2ee8 - std::panicking::default_hook::{{closure}}::he1ad87607d0c11c5
4: 0x7fd8b92f3d9d - std::panicking::rust_panic_with_hook::had2118629c312a4a
5: 0x7fd8b92f3885 - std::panicking::begin_panic_handler::{{closure}}::h7fa5985d111bafa2
6: 0x7fd8b92f37e9 - std::sys::backtrace::__rust_end_short_backtrace::h704d151dbefa09c5
7: 0x7fd8b92f37d4 - rust_begin_unwind
8: 0x7fd8b8fed8f2 - core::panicking::panic_fmt::h3eea515d05f7a35e
9: 0x7fd8b8fedcd5 - core::result::unwrap_failed::h7c8d8bbbcf45dc13
10: 0x7fd8b915d8e7 - core::ptr::drop_in_place<core::iter::adapters::take_while::TakeWhile<py_spy::sampler::Sampler,<pyroscope_pyspy::Pyspy as pyroscope::backend::backend::Backend>::initialize::{{closure}}::{{closure}}>>::hb8598e2051333fd8
11: 0x7fd8b915c495 - std::sys::backtrace::__rust_begin_short_backtrace::hdd313e918d19a86d
12: 0x7fd8b9157ed8 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hd8dd98709d2949ce
13: 0x7fd8b92f4feb - std::sys::pal::unix::thread::Thread::new::thread_start::hcdbd1049068002f4
14: 0x7fd90b0b9ac3 - <unknown>
15: 0x7fd90b14aa04 - clone
16: 0x0 - <unknown>
Environment
- ubuntu:22.04 Docker image
- Python 3.13.1
- PyPI pyroscope-io@0.8.8