-
Notifications
You must be signed in to change notification settings - Fork 544
CXX-2723 Explicitly document throwing exception from APM callback is undefined behavior #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
re: Catch2 issues: Only REQUIRE
throws exceptions, and looking at the file I would guess that it should be using CHECK()
or CHECKED_IF()
instead of REQUIRE
for every condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is considered too excessive (consider: our own test cases violate this requirement in failure conditions, as Catch2 uses exceptions to report test assertion failures), we can omit the addition of
noexcept
specifiers.
I prefer the well defined terminate to undefined behavior.
This reverts commit 8c80834.
Resolves CXX-2723. Verified by this patch.
Adds explicit documentation in the form of a warning that throwing an exception from an APM callback is undefined behavior. This requirement has always existed but was not properly documented.
As a QoI improvement, despite (now) being explicitly documented as UB, this PR proposes adding
noexcept
specifiers to the internal APM callback functions (the actual callback that invokes the registered user-provided callback) to reduce the scope of runtime errors should this requirement be violated, as control flow should not have returned from libmongoc via an exception to begin with (the program is already in an invalid state at this point). Any user code that currently violates the nothrow requirement will now terminate vianoexcept
rather than be allowed to continue with potentially unbounded libmongoc runtime errors. If this is considered too excessive (consider: our own test cases violate this requirement in failure conditions, as Catch2 uses exceptions to report test assertion failures), we can omit the addition ofnoexcept
specifiers.As a drive-by improvement, ran
doxygen -u
to update the Doxyfile to address obsolete tag warnings (TCL_SUBST
,COLS_IN_ALPHA_INDEX
,PERL_PATH
,MSCGEN_PATH
).