Open akiross opened 5 years ago
Hello,
This means frame.f_back
is None (frame is topmost), but call stack is not empty (so there is a known caller). The error traceback is consistent with no caller existing (_remove
is being called from nowhere, maybe hidden gc
magic ?). Or some threading magic (but I doubt it) ?
I suspect the bug is in pprofile, but to properly fix it I will need your help understanding why it triggers. As a first step you can add an if frame.f_back is not None:
in _real_global_trace
's else:
block so it does not execute if there is no caller frame.
Hello, I am sorry, but I am unable to help on this matter anymore: changed job, I no longer have the codebase where this happened.
as a headsup - I got exactly the same error running python -m trace -t -g -c -C 'path/to/coveragedir'
so it looks more fundamental than your library
Also came across this issue with a similar setup, any ideas on how to fix this?
Traceback (most recent call last):
File "/usr/lib/python3.8/_weakrefset.py", line 38, in _remove
def _remove(item, selfref=ref(self)):
File "/usr/local/lib/python3.8/dist-packages/pprofile/__init__.py", line 1042, in _real_global_trace
def _remove(item, selfref=ref(self)):
File "/usr/local/lib/python3.8/dist-packages/pprofile/__init__.py", line 1042, in _real_global_trace
callee_dict[(frame.f_back.f_code, frame.f_code)].append(callee_entry)def _remove(item, selfref=ref(self)):
File "/usr/local/lib/python3.8/dist-packages/pprofile/__init__.py", line 1042, in _real_global_trace
AttributeError: callee_dict[(frame.f_back.f_code, frame.f_code)].append(callee_entry)
AttributeError: 'NoneType' object has no attribute 'f_code''NoneType' object has no attribute 'f_code'
Aha !
Does the code being profiled (or its dependencies) use generators, including coroutines ?
This does not seem to be enough on its own, so something else is needed to trigger this issue. So far I do not see what, and I must say that I have never dug into coroutines (...and I suspect the caller/callee notion just melts in such context), although I am familiar with garden-variety generators.
In my case a ROS node is profiled, involving msg passing and service calls. So its highly probable that coroutines are involved. However my knowledge on coroutines and generators is fairly shallow.
Thanks for responding btw!
Hello, thanks for pprofile! I got this exception while trying to run a script, and apparently this is being raised just before (or at the beginning) of my script. Also, it is not deterministic: the same script launched with the same inputs will not raise this exception every time.
I launched with
pprofile --output /path/to/out.txt myscript.py
, if it is of any interest. Did I do something wrong or is this a bug? In the latter case, please let me know if I can do something more to help.