Disjoint stacks with embedded Python interpreter
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Profiling native applications employing embedded Python interpreter instances with native tracking enabled (--native) yields disjoint Python stacks.
Reporters are unable to match native stack frames against Python frames, since the following check doesn't work as designed: https://github.com/bloomberg/memray/blob/80a3baa1a412c3924f6782bdc2038f032534201b/src/memray/_memray.pyx#L230
At least with our libpython3.11.so frame _PyEval_EvalFrameDefault is missing from the native stacks, instead only _PyEval_EvalFrame is present
The check should actually look like this:
for nidx, native_frame in enumerate(native_stack):
symbol = native_frame[0]
if pidx >= 0 and ("_PyEval_EvalFrameDefault" in symbol
or ("_PyEval_EvalFrame" in symbol
and (nidx == len(native_stack) - 1
or "_PyEval_EvalFrameDefault" not in native_stack[nidx + 1][0]))):it additionally tries to guard against a nested call to _PyEval_EvalFrameDefault.
Expected Behavior
Python stacks are shown embedded in native stacks.
Steps To Reproduce
Too complicated to provide a small repro.
Memray Version
1.17.2
Python Version
3.11
Operating System
Linux
Anything else?
No response
Source: bloomberg/memray