You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a case where py-spy computes the wrong address for PyRuntime and then fails to get the PyInterpreterState head ptr.
I suspect the issue is due to binary_parser.rs computes the address of PyRuntime given the symbol from the file. Possibly due to ASLR, but I have not looked too hard at this. However after disabling ASLR (via sudo sysctl -w kernel.randomize_va_space=0) py-spy works consistently.
Python version: 3.11.10
OS: linux, nix
py-spy debug output
[2024-12-04T00:06:07.953583877Z DEBUG py_spy::python_process_info] map: 00007f31d7000000-00007f31d720c000 r-- /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython
3.11.so.1.0
[2024-12-04T00:06:07.953633198Z DEBUG py_spy::python_process_info] map: 00007f31d720c000-00007f31d7f95000 r-x /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython
3.11.so.1.0
[2024-12-04T00:06:07.953680154Z DEBUG py_spy::python_process_info] map: 00007f31d7f95000-00007f31d8513000 r-- /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython
3.11.so.1.0
[2024-12-04T00:06:07.953728270Z DEBUG py_spy::python_process_info] map: 00007f31d8513000-00007f31d85f1000 r-- /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython
3.11.so.1.0
[2024-12-04T00:06:07.953776521Z DEBUG py_spy::python_process_info] map: 00007f31d85f1000-00007f31d874b000 rw- /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython
3.11.so.1.0
...
[2024-12-04T00:06:07.957910205Z INFO py_spy::python_process_info] Found libpython binary @ /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython3.11.so.1.0
[2024-12-04T00:06:08.062811682Z INFO py_spy::python_process_info] got symbol Py_GetVersion.version (0x00007f31d826bf60) from libpython binary
[2024-12-04T00:06:08.062874534Z INFO py_spy::python_process_info] Getting version from symbol address
[2024-12-04T00:06:08.062949754Z INFO py_spy::python_process_info] Getting version from python binary BSS
[2024-12-04T00:06:08.062968650Z INFO py_spy::python_process_info] Failed to get version from BSS section: failed to find version string
[2024-12-04T00:06:08.062981071Z INFO py_spy::python_process_info] Getting version from libpython BSS
[2024-12-04T00:06:08.063119642Z INFO py_spy::version] Found matching version string '3.11.10 (main)'
[2024-12-04T00:06:08.063141548Z INFO py_spy::python_spy] python version 3.11.10 detected
[2024-12-04T00:06:08.063156220Z INFO py_spy::python_process_info] got symbol _PyRuntime (0x00007f31d8202850) from libpython binary
[2024-12-04T00:06:08.063239741Z WARN py_spy::python_process_info] Interpreter address from _PyRuntime symbol is invalid 5f646e655f736576
[2024-12-04T00:06:08.063252698Z INFO py_spy::python_process_info] Failed to find runtime address from symbols, scanning BSS section from main binary
[2024-12-04T00:06:08.063277528Z INFO py_spy::python_process_info] Failed to get interpreter from binary BSS, scanning libpython BSS
(lldb) tar mo loo -s _PyRuntime -A
1 symbols match '_PyRuntime' in /home/yiding/.local/share/uv/python/cpython-3.11.10-linux-x86_64-gnu/lib/libpython3.11.so.1.0:
Address: libpython3.11.so.1.0[0x0000000001721850] (libpython3.11.so.1.0.PT_LOAD[3]..PyRuntime + 0)
Summary: libpython3.11.so.1.0`_PyRuntime
(lldb) p &_PyRuntime
(void **) 0x00007f31d8721850
The text was updated successfully, but these errors were encountered:
I ran into a case where py-spy computes the wrong address for PyRuntime and then fails to get the PyInterpreterState head ptr.
I suspect the issue is due to binary_parser.rs computes the address of PyRuntime given the symbol from the file. Possibly due to ASLR, but I have not looked too hard at this. However after disabling ASLR (via
sudo sysctl -w kernel.randomize_va_space=0
) py-spy works consistently.Python version: 3.11.10
OS: linux, nix
py-spy debug output
Objdump output of the libpython binary:
Actual _PyRuntime address as computed by lldb:
The text was updated successfully, but these errors were encountered: