Current icon indicating copy to clipboard operation
Current copied to clipboard

Add and use top-level `TriggerSegmentationFault()` for critical invariant checks?

Open dkorolev opened this issue 6 years ago • 0 comments

Hi @mzhurovich, @grixa, @nyospe,

I'm finding my code to have a few CURRENT_THROW( ... _internal error_ ...) exceptions, which, during debugging, I often end up forcefully making into SEGFAULT-s to get a stack trace. Here is how it's done (originally found as part of googletest).

inline void TriggerSegmentationFault() { *reinterpret_cast<volatile int*>(0) = 0; }

Now I am thinking: if an error is indeed critical and not recoverable, and if it makes debugging easier (stack trace available) with a solid crash, perhaps it's a good idea to just add TriggerSegmentationFault() into the top-level port.h and to not hesitate to use it instead of a yet another kind-of-unrecoverable CURRENT_THROW(ModuleXInternalError()).

What do you think?

dkorolev avatar Mar 26 '19 16:03 dkorolev