Skip to content

runtime/tracer: passthrough unexpected signals by default #488

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kkysen
Copy link
Contributor

@kkysen kkysen commented Dec 19, 2024

This allows signals like SIGABRT to work in tests, so now asserts work correctly, like in the post_condition test. Since post condition functions can be arbitrary and the user can handle things any way, we don't want to impose an unnecessary restriction on what fatal signals they may raise.

@kkysen kkysen force-pushed the kkysen/post-condition-negative-control branch from 063b46d to bb6f17c Compare December 20, 2024 19:41
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch from 5c8ecfc to 6b5aa0e Compare December 21, 2024 15:00
@kkysen kkysen force-pushed the kkysen/post-condition-negative-control branch from 08a547e to c1a26d3 Compare December 21, 2024 15:15
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch from 6b5aa0e to e346f66 Compare December 21, 2024 15:19
@kkysen kkysen force-pushed the kkysen/post-condition-negative-control branch from c1a26d3 to 80f3d9c Compare January 21, 2025 17:05
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch from e346f66 to dd7993a Compare January 21, 2025 17:05
@kkysen kkysen force-pushed the kkysen/post-condition-negative-control branch from 80f3d9c to 8db716a Compare January 27, 2025 05:02
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch from dd7993a to f9e812b Compare January 27, 2025 05:03
@fw-immunant fw-immunant self-assigned this Jan 27, 2025
Copy link
Contributor

@fw-immunant fw-immunant left a comment

Choose a reason for hiding this comment

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

See inline comments.

Comment on lines +132 to +160
if (exit_status != test_info->exit_code ||
// Sometimes the signal doesn't show up with `WIFSIGNALED`, so we check the exit status as well.
(exit_status > 128 && exit_status - 128 == test_info->signal)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems wrong. The first half checks if the exit status is not what's expected (which is a problem). We or this against the exit status indicating we received the expected signal (which is not a problem).

Copy link
Contributor Author

@kkysen kkysen Feb 18, 2025

Choose a reason for hiding this comment

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

I think it is wrong here, but it was simpler to redo this logic in #499, which I've updated more now. If #499 looks okay, can you look there instead for this logic?

@@ -817,7 +836,7 @@ bool track_memory_map(pid_t pid, int *exit_status_out, enum trace_mode mode) {
case WAIT_SIGNALED: {
fprintf(stderr, "process received fatal signal (syscall entry)\n");
enum control_flow cf = handle_process_exit(&maps, waited_pid);
return false;
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Making this return true without setting *exit_status_out violates the doc comment for track_memory_map. This needs changes in wait_for_next_trap, which currently only writes through its copy of the exit_status_out pointer when returning WAIT_EXITED

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed things to always return the wait status, which can then be inspected more thoroughly with all of the W* macros.

@kkysen kkysen force-pushed the kkysen/post-condition-negative-control branch from 8db716a to 8fd3e24 Compare February 17, 2025 01:38
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch 5 times, most recently from 7adfbaf to 44b5f63 Compare February 18, 2025 05:31
@kkysen kkysen requested a review from fw-immunant February 18, 2025 05:32
Base automatically changed from kkysen/post-condition-negative-control to main February 19, 2025 01:48
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch from 44b5f63 to adfaf96 Compare February 19, 2025 02:22
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch 3 times, most recently from ca1f7be to f177818 Compare March 7, 2025 21:18
kkysen added 3 commits March 10, 2025 17:02
This allows signals like `SIGABRT` to work in tests,
so now `assert`s work correctly, like in the `post_condition` test.
Since post condition functions can be arbitrary and the user can handle things any way,
we don't want to impose an unnecessary restriction on what fatal signals they may raise.
When the test child process dies from a fatal signal,
it seems to sometimes trigger `WIFSIGNALED`,
but sometimes just shows up in the `WEXITSTATUS` as `128 + signal`.
Thus, this handles both cases.
Now `STRINGIFY(EXIT_SUCCESS)` is "EXIT_SUCCESS" not "0" for example.
The other expanding version is now called `EXPAND_AND_STRINGIFY`.
@kkysen kkysen force-pushed the kkysen/tracer-passthrough-unexpected-signals branch from f177818 to 84f8c8a Compare March 12, 2025 19:37
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