Skip to content

panic with Python 3.12 on Linux #735

Open
@bouweandela

Description

@bouweandela

When trying to profile my Python program with py-spy 0.4.0, the tool crashes with the following stack trace:

thread '<unnamed>' panicked at src/python_interpreters.rs:257:16:
index out of bounds: the len is 11 but the index is 11
stack backtrace:
   0:     0x7ffff7c28075 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h358afad87e02ca76
   1:     0x7ffff7c6277b - core::fmt::write::hb19b5b269a2fe458
   2:     0x7ffff7c2545f - std::io::Write::write_fmt::he5a92676a45ef09d
   3:     0x7ffff7c291c1 - std::panicking::default_hook::{{closure}}::h3bff550b24d93725
   4:     0x7ffff7c28e9c - std::panicking::default_hook::hd53b1b06d2b99687
   5:     0x7ffff7c29821 - std::panicking::rust_panic_with_hook::h9fdd87cddb2763da
   6:     0x7ffff7c29687 - std::panicking::begin_panic_handler::{{closure}}::h089783ab6b5cba45
   7:     0x7ffff7c28539 - std::sys::backtrace::__rust_end_short_backtrace::hed34776d77ef7922
   8:     0x7ffff7c29314 - rust_begin_unwind
   9:     0x7ffff7872453 - core::panicking::panic_fmt::h300583f35f37447a
  10:     0x7ffff78725e7 - core::panicking::panic_bounds_check::hbdc1cc1e8fde102f
  11:     0x7ffff796ee9e - <py_spy::python_bindings::v3_12_0::PyCodeObject as py_spy::python_interpreters::CodeObject>::get_line_number::h365860ffb62d2018
  12:     0x7ffff78c750a - py_spy::stack_trace::get_stack_trace::hf218688a270a5d72
  13:     0x7ffff790a26c - py_spy::python_spy::PythonSpy::get_stack_traces::he097640af52b1cd3
  14:     0x7ffff78cb9bc - std::sys::backtrace::__rust_begin_short_backtrace::hb23a7328ba172b05
  15:     0x7ffff78cd11b - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0aa6e250e2ff7269
  16:     0x7ffff7c2dedb - std::sys::pal::unix::thread::Thread::new::thread_start::h4233e449bef376b8
thread 'main' panicked at src/sampler.rs:264:22:
called `Result::unwrap()` on an `Err` value: Any { .. }
stack backtrace:
   0:     0x7ffff7c28075 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h358afad87e02ca76
   1:     0x7ffff7c6277b - core::fmt::write::hb19b5b269a2fe458
   2:     0x7ffff7c2545f - std::io::Write::write_fmt::he5a92676a45ef09d
   3:     0x7ffff7c291c1 - std::panicking::default_hook::{{closure}}::h3bff550b24d93725
   4:     0x7ffff7c28e9c - std::panicking::default_hook::hd53b1b06d2b99687
   5:     0x7ffff7c29821 - std::panicking::rust_panic_with_hook::h9fdd87cddb2763da
   6:     0x7ffff7c29687 - std::panicking::begin_panic_handler::{{closure}}::h089783ab6b5cba45
   7:     0x7ffff7c28539 - std::sys::backtrace::__rust_end_short_backtrace::hed34776d77ef7922
   8:     0x7ffff7c29314 - rust_begin_unwind
   9:     0x7ffff7872453 - core::panicking::panic_fmt::h300583f35f37447a
  10:     0x7ffff78728c6 - core::result::unwrap_failed::h83aef6e0d2ac917f
  11:     0x7ffff78d9c47 - <py_spy::sampler::Sampler as core::ops::drop::Drop>::drop::h1ba800bed70b82d3
  12:     0x7ffff797b957 - core::ptr::drop_in_place<py_spy::sampler::Sampler>::h34a0d6b83f4f8872
  13:     0x7ffff7989a62 - py_spy::run_spy_command::h03dd3ae83f79b8f1
  14:     0x7ffff798ae5a - py_spy::main::h1d83dfa3c485e787
  15:     0x7ffff78cb6e3 - std::sys::backtrace::__rust_begin_short_backtrace::haedd4627941893a7
  16:     0x7ffff7966909 - std::rt::lang_start::{{closure}}::h92ff100211e3319f
  17:     0x7ffff7c1dd07 - std::rt::lang_start_internal::h93b3b742566fb30c
  18:     0x7ffff798b8e5 - main

The python version is:

$ python --version --version
Python 3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 16:05:46) [GCC 13.3.0]

The command I run:

py-spy record \
--idle \
--nonblocking \
--rate 10 \
--format speedscope \
--output "$output" \
program with some commands

Please let me know if there is any additional information that I can provide to help with identifying the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions