benfred / py-spy

Sampling profiler for Python programs
MIT License
12.14k stars 400 forks source link

Python 3.12 support #620

Closed konstin closed 8 months ago

konstin commented 8 months ago

When trying to profile python 3.12 code, i get occasional, non-deterministic crashes with a message that python 3.12 is not supported (i assume they only happen when a frame is hit that actually looks different in python 3.12, so i only see them after a while). It would be great if py-spy could support python 3.12.

benfred commented 8 months ago

I'm working on adding python 3.12 support right now, I have a very rough version available that can at least get basic stack traces - but still need to add in support for line numbers, thread names etc.

i get occasional, non-deterministic crashes with a message that python 3.12 is not supported

Right now - you should be getting deterministic crashes that python 3.12 is not supported. One of the first things py-spy does is get the python version, and then uses the python version to figure out which interpreter layout to use. If the python version doesn't match known versions - it should error out with https://github.com/benfred/py-spy/blob/75adc45e6323e654ec21780bec60b182e2980b7b/src/python_spy.rs#L181-L184

I'm really confused that you are able to get any traces at all from python 3.12 =(. Can you try running with RUST_LOG=info py-spy <your args> to generate some debugging info for me?

konstin commented 8 months ago

Strange, when i try to reproduce it now i correctly get

Error: Unsupported version of Python: 3.12.0