__assert_fail should not be __attribute__((__noreturn__))

Johannes Sixt johannes.sixt@telecom.at
Sat Apr 3 20:24:00 GMT 2004


It would be helpful if __assert_fail were not declared as 
__attribute__((__noreturn__)). __assert_fail can be replaced by LD_PRELOADing 
a shared object that implements a version that does not raise(SIGABRT) so 
that any assertions are in fact ignored. However, this fails because gcc 
makes extensive use of __attribute__((__noreturn__)) (and generates no stack 
cleanup code).

In fact, I'm writing a shared object that invokes a debugger. From the 
debugger it is easy to decide whether the assertion can be ignored, or the 
error cause can be removed by changing some program value. After doing so, it 
should be possible to continue the program.

I see no disadvantages if __assert_fail is a plain function. If the program is 
not compiled with NDEBUG, there is already the code size and runtime overhead 
for the condition check; I think that the stack cleanup penalty is 
justifyable. Could this be changed, please? I propose something like in the 
patch below.

-- Hannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: assertfail.diff
Type: text/x-diff
Size: 900 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20040403/ccd29eda/attachment.bin>


More information about the Libc-alpha mailing list