Skip to content

range end index out of range error in pyo3-introspection #5023

@abrisco

Description

@abrisco

Bug Description

I'm trying to use the new pyo3-introspection crate (introduced in #3977) to generate stubs and ran into a panic when trying this on my MacOS arm64 machine. The binary I wrote to try and generate stubs is @rules_pyo3//pyo3/private/stubgen.rs. The pyo3 module is being built optimized but I did try debug and got the same result.

Steps to Reproduce

  1. Clone https://github.com/abrisco/rules_pyo3/tree/stubgen
  2. Run bazel build //pyo3/private/tests/string_sum:string_sum

Backtrace

thread 'main' panicked at external/+rust_ext+rpyo3c__pyo3-introspection-0.25.0-dev/src/introspection.rs:214:38:
range end index 9007199255016033 out of range for slice of length 478128
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::slice::index::slice_end_index_len_fail::do_panic::runtime
   3: core::slice::index::slice_end_index_len_fail
   4: pyo3_introspection::introspection::read_symbol_value_with_ptr_and_len
   5: pyo3_introspection::introspection::find_introspection_chunks_in_macho
   6: pyo3_introspection::introspection::find_introspection_chunks_in_binary_object
   7: pyo3_introspection::introspection::introspect_cdylib
   8: stubgen::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Your operating system and version

MacOS arm64

Your Python version (python --version)

Python 3.11.11

Your Rust version (rustc --version)

1.85.1 (4eb161250 2025-03-15)

Your PyO3 version

0.25.0-dev

How did you install python? Did you use a virtualenv?

None

Additional Info

I know my steps to repro are Bazel but I can work with someone to get more canonical repro steps. My hope was that I could provide enough info so that the issue might be obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions