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
RMW_IMPLEMENTATION=rmw_opensplice_cpp ros2 run image_tools cam2image
Expected behavior
Normal termination upon SIGINT receival.
Actual behavior
Sporadically, it shows:
terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'what(): Failed to create interrupt guard condition in Executor constructor: the given context is not valid, either rcl_init() was not called or rcl_shutdown() was called., at /tmp/binarydeb/ros-crystal-rcl-0.6.1/src/rcl/guard_condition.c:69
I don't think it's related to #604 personally, I believe it's a case where the code is trying to create an executor after shutdown is called. You're probably ctrl-c'ing before the executor can be constructed, in which case it's no longer valid to create one (or more precisely it no longer valid to create a guard condition at this point which is what's actually failing).
There are cases where doing something after shutdown is ok and where it's invalid to do that after shutdown.
@sloretz and I had a discussion about this before and there's basically four cases for what to do when something is performed after shutdown:
throw (as is the case here)
fail gracefully (e.g. is publish will not send data, but will also not throw)
fail gracefully in certain conditions (e.g. maybe publish should fail gracefully, but only once per thread)
continue to work as normal (e.g. maybe publish for /rosout should continue to work after shutdown)
We didn't decide at the time what to do about it, but I think it's a good thing that we're finding places where normal operations are being performed after shutdown (likely a bug in a lot of cases). In this particular case, I think it would be ok to not throw here, given that the executor would shut itself down afterwards.
We can choose to three things here (as I see it):
do nothing
the thought being this like KeyboardInterrupt in Python, you could wrap your main in a try-catch if you want to avoid it when you ctrl-c randomly in your program
allow guard condition creation during executor, allowing executor to be constructed
but spin will still exit immediately when it checks rclcpp::ok() internally
extend API's (including guard condition creation) to take a bool like work_even_in_shutdown which ignores the state of the context, allowing the executor to be constructed and function after shutdown
only really useful if the scenario calls for functioning after shutdown, imo not the case here
Activity
wjwwood commentedon Dec 11, 2018
I don't think it's related to #604 personally, I believe it's a case where the code is trying to create an executor after shutdown is called. You're probably ctrl-c'ing before the executor can be constructed, in which case it's no longer valid to create one (or more precisely it no longer valid to create a guard condition at this point which is what's actually failing).
There are cases where doing something after shutdown is ok and where it's invalid to do that after shutdown.
@sloretz and I had a discussion about this before and there's basically four cases for what to do when something is performed after shutdown:
/rosoutshould continue to work after shutdown)We didn't decide at the time what to do about it, but I think it's a good thing that we're finding places where normal operations are being performed after shutdown (likely a bug in a lot of cases). In this particular case, I think it would be ok to not throw here, given that the executor would shut itself down afterwards.
We can choose to three things here (as I see it):
KeyboardInterruptin Python, you could wrap your main in a try-catch if you want to avoid it when you ctrl-c randomly in your programrclcpp::ok()internallywork_even_in_shutdownwhich ignores the state of the context, allowing the executor to be constructed and function after shutdownivanpauno commentedon Jun 25, 2020
Closing in favor of #1139, which has a more recent discussion.
Add visibility to rcl_timer_get_allocator (ros2#610)