Closed Vipul-Cariappa closed 3 months ago
We register loc_abort_callback_print_stack as a callback on the SIGABRT signal and loc_segfault_callback_print_stack on the SIGSEGV signal. (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L530-L531)
loc_abort_callback_print_stack
SIGABRT
loc_segfault_callback_print_stack
SIGSEGV
Tracing the flow of function calls: loc_abort_callback_print_stack and loc_segfault_callback_print_stack calls get_stacktrace (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L524 & https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L516) get_stacktrace calls get_local_addresses (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L537) get_local_addresses calls get_local_address (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L561) get_local_address calls abort. (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L142)
get_stacktrace
get_local_addresses
get_local_address
abort
So while handling SIGABRT we end up regenerating SIGABRT and the cycle repeats. To prevent this, I have changed the abort() to exit(1) to immediately exit.
abort()
exit(1)
I observed this while working on #2564 and #2595.
I think this is a Great catch! Thanks! I am curious how did you debug this?
We register
loc_abort_callback_print_stack
as a callback on theSIGABRT
signal andloc_segfault_callback_print_stack
on theSIGSEGV
signal. (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L530-L531)Tracing the flow of function calls:
loc_abort_callback_print_stack
andloc_segfault_callback_print_stack
callsget_stacktrace
(reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L524 & https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L516)get_stacktrace
callsget_local_addresses
(reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L537)get_local_addresses
callsget_local_address
(reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L561)get_local_address
callsabort
. (reference: https://github.com/lcompilers/lpython/blob/main/src/libasr/stacktrace.cpp#L142)So while handling
SIGABRT
we end up regeneratingSIGABRT
and the cycle repeats. To prevent this, I have changed theabort()
toexit(1)
to immediately exit.I observed this while working on #2564 and #2595.