Users of the ON_BLOCK_EXIT macro may not be aware that the callback function they are passing to it runs in a noexcept context, and that any exception escaping from it will terminate the process.
While it is clear when writing a destructor that it is implicitly noexcept and that exceptions should be handled, it is less clear when writing code using the ON_BLOCK_EXIT macro. SERVER-100707 is a real world issue that led to a server crash because an exception escaped an ON_BLOCK_EXIT callback function. There may be more such issues.
We could improve on this by adding code comments to both the ScopeGuard class and the ON_BLOCK_EXIT macro, stating that the callback function will run in a noexcept context and that callers are responsible for handling exceptions in their callback function, and failure to do so will result in process termination.
- is related to
-
SERVER-100707 Avoid throwing an exception in DocumentSourceCursor
-
- Closed
-