g_error does not abort() as documented
The documentation for g_error
says:
Error messages are always fatal, resulting in a call to
abort()
to terminate the application.
This is however not true since 2.39.1-82-g695070b5, since then it raises a SIGTRAP instead of SIGABRT (on Linux, not on Windows.)
Reproducer
printf '%s\n' '#include <glib.h>' 'int main(){ g_error("ping"); }' | cc -xc - `pkg-config --cflags --libs glib-2.0`
./a.out; echo $?
Expected result
** (process:...): ERROR **: ...: ping
Aborted (core dumped)
134
Actual result
** (process:...): ERROR **: ...: ping
Trace/breakpoint trap (core dumped)
133
Additional information
This issue prevents Address Sanitizer from producing a nice backtrace (with ASAN_OPTIONS=handle_abort=1
). With Clang 7 (unreleased), a new handle_sigtrap=1
option can be used to handle the current situation. Since it is not officially released yet, I am using a workaround that LD_PRELOAD
s a library that aborts on SIGTRAP.