Skip to content
This repository was archived by the owner on Jun 19, 2026. It is now read-only.

misc/test_runner: Replace _exit after segfault with syscall#623

Merged
ayrtonm merged 1 commit into
mainfrom
am/test_exit
Aug 11, 2025
Merged

misc/test_runner: Replace _exit after segfault with syscall#623
ayrtonm merged 1 commit into
mainfrom
am/test_exit

Conversation

@ayrtonm

@ayrtonm ayrtonm commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

libia2.a provides exit, _exit and call_libc_exit but we can't call any of these after catching a segfault because we're in a signal handler at that point. exit accesses ia2_stackptr_0 (a thread-local) using the %fs segment register which does not work from a signal handler. _exit just jumps to exit so it also doesn't work for the same reason and call_libc_exit calls dlopen which calls many functions that are not async-signal-safe. This commit replaces the call to _exit in the signal handler for tests with a syscall for exit instead. Originally part of PR #589.

Comment thread misc/test_runner/test_runner.c

@kkysen kkysen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can call_libc_exit call __real_exit instead? That way it wouldn't need to go through dlsym?

Or __real__exit.

libia2.a provides exit, _exit and call_libc_exit but we can't call any of these
after catching a segfault because we're in a signal handler at that point. exit
accesses ia2_stackptr_0 (a thread-local) using the %fs segment register whihc
does not work from a signal handler. _exit just jumps to exit so it also doesn't
work for the same reason and call_libc_exit calls dlopen which calls many
functions that are not async-signal-safe. This commit replaces the call to _exit
in the signal handler for tests with a syscall for exit instead.
@ayrtonm

ayrtonm commented Aug 11, 2025

Copy link
Copy Markdown
Contributor Author

Can call_libc_exit call __real_exit instead? That way it wouldn't need to go through dlsym?

This doesn't work since we override exit by defining a new exit symbol rather than using -Wl,--wrap=exit.

@ayrtonm ayrtonm merged commit 63eb81c into main Aug 11, 2025
35 checks passed
@ayrtonm ayrtonm deleted the am/test_exit branch August 11, 2025 21:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants