Skip to content

Commit

Permalink
Document issue with shutdown (#283)
Browse files Browse the repository at this point in the history
* Document issue with shutdown

Signed-off-by: Yadunund <yadunund@intrinsic.ai>

* Update README.md

Co-authored-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Yadu <yadunund@gmail.com>

* Update README.md

Co-authored-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Yadu <yadunund@gmail.com>

* Update README.md

Co-authored-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Yadu <yadunund@gmail.com>

---------

Signed-off-by: Yadunund <yadunund@intrinsic.ai>
Signed-off-by: Yadu <yadunund@gmail.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
  • Loading branch information
Yadunund and clalancette authored Oct 1, 2024
1 parent 9bf5b74 commit cf8e8a2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,28 @@ For instance:
- `RUST_LOG=zenoh=debug` activates all the debug logs.

For more information on the `RUST_LOG` syntax, see https://docs.rs/env_logger/latest/env_logger/#enabling-logging.

### Known Issues

### Crash when program terminates

When a program terminates, global and static objects are destructed in the reverse order of their
construction.
The `Thread Local Storage` is one such entity which the `tokio` runtime in Zenoh uses.
If the Zenoh session is closed after this entity is cleared, it causes a panic like seen below.

```
thread '<unnamed>' panicked at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/thread/local.rs:262:26:
cannot access a Thread Local Storage value during or after destruction: AccessError
```

This can happen with `rmw_zenoh` if the ROS 2 `Context` is not shutdown explicitly before the
program terminates.
In this scenario, the `Context` will be shutdown inside the `Context`'s destructor which then closes the Zenoh session.
Since the ordering of global/static objects is not defined, this often leads to the above panic.

The recommendation is to ensure the `Context` is shutdown before a program terminates.
One way to ensure this is to call `rclcpp::shutdown()` when the program exits.
Note that composable nodes should *never* call `rclcpp::shutdown()`, as the composable node container will automatically do this.

For more details, see https://github.com/ros2/rmw_zenoh/issues/170.

0 comments on commit cf8e8a2

Please sign in to comment.