[Bug other/67520] New: libmpx should abort() instead of exit(255) on bound violation detection
jussi.judin at ericsson dot com
gcc-bugzilla@gcc.gnu.org
Wed Sep 9 14:27:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67520
Bug ID: 67520
Summary: libmpx should abort() instead of exit(255) on bound
violation detection
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: jussi.judin at ericsson dot com
Target Milestone: ---
libmpx should do an action that can be easily caught in a debugger or runtime
testing program (like core dump) instead of doing exit(255) whenever bound
violation error is detected. Currently libmpx apparently does following in
libmpx/mpxrt/mpxrt.c if environment variable CHKP_RT_MODE=stop:
if (__mpxrt_mode () == MPX_RT_STOP)
exit (255);
To catch this I need to change the program under test to include a exit handler
that looks for exit code 255 with the assumption that nothing else triggers
exit code 255:
#include <stdint.h>
#include <stdlib.h>
static void exit_abort(int code, void* wanted_code)
{
if (code == (intptr_t)wanted_code)
{
abort();
}
}
int main()
{
static int foo[50];
int* bar = foo;
on_exit(exit_abort, (void*)(intptr_t)255);
return bar[50];
}
Compiling this with "-g3 -fno-omit-frame-pointer -fcheck-pointer-bounds -mmpx"
and linking mpx-runtime64 from Intel achieves the wanted result of being able
to immediately examine the program when such abort happens. But in this case
you need to modify the original program and know that the program will exit
with code 255 when it hits this failing bound violation check. It would be much
more easy to have the program to abort and result in a core dump or SIGABRT
signal capture in a debugger.
So what about changing CHKP_RT_MODE environmental variable to also include
"abort" value or changing the default "stop" behavior to abort instead of
exit(255)?
More information about the Gcc-bugs
mailing list