Skip to content

Abnormal termination after SIGINT #610

Closed

Description

@hidmic

Bug report

Required Info:

  • Operating System:
  • Installation type:
    • Binary (debs)
  • Version or commit hash:
    • Crystal pre-release.
  • DDS implementation:
    • ADLink OpenSplice 6.9
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Run and Ctrl+C the following command a few times:

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

Additional information

May be related to #604.

Activity

  1. wjwwood commented on Dec 11, 2018

    @wjwwood
    Member

    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
  2. added
    bug
    on Dec 19, 2018
  3. ivanpauno commented on Jun 25, 2020

    @ivanpauno
    Member

    Closing in favor of #1139, which has a more recent discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions