[SERVER-53065] std::terminate handler must learn to print ASSERT failures Created: 24/Nov/20  Updated: 29/Oct/23  Resolved: 17/Dec/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Billy Donahue
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-53035 provide a way to ASSERT from a non-ma... Closed
Backwards Compatibility: Fully Compatible
Sprint: Service arch 2020-12-28
Participants:

 Description   

ASSERT statements in unit tests throw TestAssertionFailureException.
It is deliberately not derived from std::exception or anything else, so that users won't be tempted to catch it. But the terminate handler is special. The process is dying and this is the only chance we have to figure out what the heck happened. We could make a special carve out for the terminate handler to catch and print TestAssertionFailureException.

Idea:

We can even do this by making the terminate handler wildcard catch(...) go through a global registry of Lippincott functions to see if any of them can identify the current exception and produce good diagnostics for it. It's perhaps unreasonable to expect that the global terminate handler can have a special case for every kind of exception that might be active. Libraries (fmt, boost, unittest) introduce their own exception types. That's fine as long as they can also add handlers to print diagnostics.



 Comments   
Comment by Githook User [ 17/Dec/20 ]

Author:

{'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}

Message: SERVER-53065 enhance terminate handler exception dumps
Branch: master
https://github.com/mongodb/mongo/commit/0dc0df8b9cc05d76b80cfb1826a7e4c376dac596

Comment by Billy Donahue [ 04/Dec/20 ]

CR https://mongodbcr.appspot.com/711710001/

Comment by Billy Donahue [ 02/Dec/20 ]

Linking SERVER-53035 which inspired this ticket. An ASSERT incorrectly performed on a non-main thread would have the following problem. Currently nothing catches that type of thrown exception, so std::terminate will fire. Our terminate handler will have no idea how to print anything about the TestAssertionFailureException, because it just isn't one of the exception types the handler was compiled with.

So it comes out of the unittest library, but it's a general problem. If we link with a library, we are linking with all of its exception types, any of which the std::terminate handler might be asked to handle. It would be useful then for the terminate handler to be extensible to accommodate those exceptions.

Generated at Thu Feb 08 05:29:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.