What are the scenarios where a process gets a SIGABRT in C++? Does this signal always come from within the process or can this signal be sent from one process to another?
Is there a way to identify which process is sending this signal?
What are the scenarios where a process gets a SIGABRT in C++? Does this signal always come from within the process or can this signal be sent from one process to another?
Is there a way to identify which process is sending this signal?
A case when process get SIGABRT from itself: Hrvoje mentioned about a buried pure virtual being called from ctor generating an abort, i recreated an example for this. Here when d is to be constructed, it first calls its base class A ctor, and passes inside pointer to itself. the A ctor calls pure virtual method before table was filled with valid pointer, because d is not constructed yet.
compile: g++ -o aa aa.cpp
ulimit -c unlimited
run: ./aa
now lets quickly see the core file, and validate that SIGABRT was indeed called:
see regs:
check code:
disas 0x7feae3170c37
http://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/
234 sys_tgkill pid_t tgid pid_t pid int sig = 6 = SIGABRT
:)
abort()
sends the calling process theSIGABRT
signal, this is howabort()
basically works.abort()
is usually called by library functions which detect an internal error or some seriously broken constraint. For examplemalloc()
will callabort()
if its internal structures are damaged by a heap overflow.