Hi, I reported a problem I have with abort to the glibc bug tracker at <URL:http://sourceware.org/bugzilla/show_bug.cgi?id=6522> which might provide some reading material.
Anyway, it has been pointed out to me that the requested change would not accomplish much anyway since GCC has its own builtin notion of the abort function. So here is my beef with the current way abort calls get optimized: basically it boils down to the interaction of -fcrossjumping (enabled with -O2) and the noreturn attribute of abort. The combination of both optimizations means that usually only one abort call will actually get compiled into a compilation unit, and all calls will instead jump there without bothering to clean the stack (after all, it is a noreturn function). This is egregiously bad when using the generated coredump (abort triggers SIGABRT) for debugging failed assertions or other aborts: neither the call/return location is correctly associated with the source code, nor is the stack/register state interpretable using debugging info. Given that the distinguishing feature of abort over exit is the creation of a core dump, it would be good if this core dump would actually be useful. I know several people who have spent days debugging at the wrong place, including myself. Currently Emacs contains in etc/DEBUG the instructions ** When you are trying to analyze failed assertions, it will be essential to compile Emacs either completely without optimizations or at least (when using GCC) with the -fno-crossjumping option. Failure to do so may make the compiler recycle the same abort call for all assertions in a given function, rendering the stack backtrace useless for identifying the specific failed assertion. However, the problem is obviously not restricted to Emacs. If the "noreturn" attribute for the internal abort were removed, at least only abort calls with compatible stack frame and the same (tentative) followup code would get folded. That would avoid the worst head-scratchers when trying to figure out what went wrong. Probably better would be to just disable the crossjumping optimization for calls of abort. Maybe this would warrant a new attribute. Thanks for caring, -- David Kastrup