Open YuanYuYuan opened 2 months ago
Maybe instead of atexit, we could use a static variable that will call all drop logic in its destructor, at least this guaranteed by C++ standard to work correctly. No apparently it is the same as calling function registered with atexit.
There are some (a lot of) system APIs that should not be called in signal handlers, so it is really a bad idea to drop big objects in signal handlers. Moreover, signal handler can be executed concurrently, so thread safety also comes into place. We need to handle signals in a safe way, I can take this task
There are some (a lot of) system APIs that should not be called in signal handlers, so it is really a bad idea to drop big objects in signal handlers. Moreover, signal handler can be executed concurrently, so thread safety also comes into place. We need to handle signals in a safe way, I can take this task
Yes. I agree with your point. Dropping objects within signal handlers isn't a good pattern. Rust has put much effort into addressing this safely within the normal scope.
Description
This issue occurs when a user tries to drop a zenoh entity in
atexit
orstd::signal
. This is also the case in rmw_zenoh_cpp. To resolve this issue, we might need to add a compilation flag to turn off thez_drop
in the destructor.To reproduce
Error log
System Info