Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Prevent calling abort while handling the SIGABRT signal #2626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

Vipul-Cariappa
Copy link
Contributor

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)

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)

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.

I observed this while working on #2564 and #2595.

@ubaidsk
Copy link
Collaborator

ubaidsk commented Mar 29, 2024

I think this is a Great catch! Thanks! I am curious how did you debug this?

Copy link
Collaborator

@ubaidsk ubaidsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me! Great work! Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants