You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By importing rosbag the standard logger is overwritte.
When sending a warning or error the logger is stuck in an indefinte loop.
This can cause other python libraries to malfunction (for example Flask).
To reproduce
import rosbag
import logging
logger = logging.getLogger('myLogger') # gets a RospyLogger object
logger.warn('message') # gets stuck in infinite loop
Infinite Loop is inside def findCaller(self, *args, **kwargs): in roslogging.py.
Afterwards it tries to find a matching stackframe (skipping the first), but there is none.
The loop to do so is a while loop, but the condition does not change, as f is not reassigned if the last frame is reached.
while hasattr(f, "f_code"):
# Search for the right frame using the data already found by parent class.
co = f.f_code
filename = os.path.normcase(co.co_filename)
if filename == file_name and f.f_lineno == lineno and co.co_name == func_name:
break
if f.f_back:
f = f.f_back
There are two things to fix:
Change the super().findCaller() so it does not return itself rather than the intended function. (Maybe stacklevel)
Prevent infinite loop by adding a else statement that does something (Throw Error?)
Alternativly do not set the global Logging class to RaspyLogger.
The text was updated successfully, but these errors were encountered:
I had this same issue running noetic compiled on Ubuntu 24.04 with python 3.12. I don't know if it was the ROS code or some change in the behavior of the underlying python that caused this to break (since there was evidently no issue on 20.04), but adding this hack to the top of the function seems to have fixed it for me:
# Increment the "stacklevel" param, be it a positional or keyword
# argument. Otherwise the call to the parent class's findCaller
# function will simply return this location.
if len(args) > 1:
args_list = list(args)
args_list[1] += 1
args = tuple(args_list)
if 'stacklevel' in kwargs:
kwargs['stacklevel'] = kwargs['stacklevel'] + 1
This is a very quick-and-dirty, barely tested first-pass, so I'm open to suggestions for better fixes.
By importing rosbag the standard logger is overwritte.
When sending a warning or error the logger is stuck in an indefinte loop.
This can cause other python libraries to malfunction (for example Flask).
To reproduce
Infinite Loop is inside
def findCaller(self, *args, **kwargs):
in roslogging.py.Cause of the issue is:
returns itself as the caller:
Afterwards it tries to find a matching stackframe (skipping the first), but there is none.
The loop to do so is a while loop, but the condition does not change, as
f
is not reassigned if the last frame is reached.There are two things to fix:
super().findCaller()
so it does not return itself rather than the intended function. (Maybe stacklevel)Alternativly do not set the global Logging class to RaspyLogger.
The text was updated successfully, but these errors were encountered: