ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
753 stars 911 forks source link

Fixed indefinite loop in roslogging.py #2353

Open StephanOLC opened 1 year ago

StephanOLC commented 1 year ago

Raising an ValueError if the caller function can not be found inside RospyLogger::findCaller() instead of looping indefinitly. Fixes #2352 partially. It prevents the function from looping indefinitely, but the correct frame is still not found.

peci1 commented 7 months ago

What if the calling function is the top-level one? Wouldn't that also satisfy the condition that there is no previous frame?

Could you try adding a unit test that fails without the fix and succeeds with it?

StephanOLC commented 6 months ago

If the top level function is the caller it should be caught by the if clause before. if filename == file_name and f.f_lineno == lineno and co.co_name == func_name: break The logic i changed affects going up the stack if the current frame is not the correct one. if f.f_back: f = f.f_back else: # Reached the last stack frame and found no matching one. raise ValueError("Could not find function [%s] on the framestack"%func_name)

A unit test could certainly be written to test it.