py-spy icon indicating copy to clipboard operation
py-spy copied to clipboard

Test python interpreters without symbols in CI

Open benfred opened this issue 1 year ago • 4 comments

The BSS scanning fallback code broke after python 3.10 was released (https://github.com/benfred/py-spy/issues/716) and we didn't notice since this we don't test this functionality out in CI.

We should add some tests that exercise this functionality as part of CI

benfred avatar Nov 01 '24 18:11 benfred

To continue the discussion from #718,

❯ nm -A `uv python find --python-preference only-system`
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _Py_Initialize
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U __NSGetExecutablePath
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U ___error
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U ___stderrp
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U ___strlcat_chk
/opt/homebrew/opt/[email protected]/bin/python3.12: 0000000100000000 T __mh_execute_header
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _dladdr
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _environ
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _err
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _exit
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _fwrite
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _malloc
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _posix_spawn
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _posix_spawnattr_init
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _posix_spawnattr_setbinpref_np
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _posix_spawnattr_setflags
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _realpath$DARWIN_EXTSN
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _setenv
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _strcpy
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _strlen
/opt/homebrew/opt/[email protected]/bin/python3.12:                  U _strrchr
❯ uv python install 3.12
Searching for Python versions matching: Python 3.12
Installed Python 3.12.7 in 1.47s
 + cpython-3.12.7-macos-aarch64-none
❯ nm -A `uv python find --python-preference only-managed`
/Users/zb/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/bin/python3:                  U _Py_BytesMain
/Users/zb/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/bin/python3: 0000000100008008 d __dyld_private
/Users/zb/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/bin/python3: 0000000100000000 T __mh_execute_header
/Users/zb/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/bin/python3: 00000001000005f0 t _main
/Users/zb/.local/share/uv/python/cpython-3.12.7-macos-aarch64-none/bin/python3:                  U dyld_stub_binder

zanieb avatar Nov 01 '24 23:11 zanieb

thanks @zanieb !

I just tested out uv quick for the first (and btw, uv is pretty slick on first impressions - I see why I've been hearing so much about it) - and I think that we're still seeing a _PyRuntime symbol , its just coming from the libpython.so rather than the main python executable (like python is compiled with --enabled-shared here).

[2024-11-02T00:02:50.323911966Z INFO  py_spy::python_process_info] Found libpython binary @ /home/ben/.local/share/uv/python/cpython-3.12.7-linux-x86_64-gnu/lib/libpython3.12.so.1.0
[2024-11-02T00:02:50.534690512Z INFO  py_spy::python_process_info] Getting version from python binary BSS
[2024-11-02T00:02:50.549518057Z INFO  py_spy::python_process_info] Failed to get version from BSS section: failed to find version string
[2024-11-02T00:02:50.549540505Z INFO  py_spy::python_process_info] Getting version from libpython BSS
[2024-11-02T00:02:50.551385878Z INFO  py_spy::version] Found matching version string '3.12.7 (main, Oct 16 2024, 04:37:19) [Clang 18.1.8 ]'
[2024-11-02T00:02:50.551398825Z INFO  py_spy::python_spy] python version 3.12.7 detected
[2024-11-02T00:02:50.551409353Z INFO  py_spy::python_process_info] got symbol _PyRuntime (0x00007ffab8ef2bd0) from libpython binary

benfred avatar Nov 02 '24 00:11 benfred

Alas. Well, good to know the distributions are compatible with a profiler even though we strip them, but too bad it's not helpful here :)

Why aren't the existing Windows tests sufficient if that's where it's usually broken?

(Glad to hear you liked uv!)

zanieb avatar Nov 02 '24 00:11 zanieb

@benfred Just a quick heads-up on https://github.com/benfred/py-spy/pull/718.

I am still seeing #593. I tried with a Python installed by uv and got:

/usr/bin/nm: /c/Users/LeimgruberF/lg/.venv/Scripts/python: no symbols

This is on Windows (using nm from MSYS2 MinGW64).

fleimgruber avatar Feb 18 '25 17:02 fleimgruber