Skip to content

Commit

Permalink
i#1973 musl: Don't pass SS_ONSTACK to sigaltstack in tests (#7198)
Browse files Browse the repository at this point in the history
POSIX.1 requires SS_ONSTACK to appear only in a stack_t retrieved from
sigaltstack(), not one passed to it. musl checks the invalid flag and
will
bail out with EINVAL before issuing a syscall in this case, failing the
test.

This commit sets ss_flags to zero instead, on both glibc and musl this
should issue a syscall, which fixes assertion failures encountered in
linux.signal*, api.static_signal and drcachesim.burst_threads on musl.

Issue: #1973
  • Loading branch information
ziyao233 authored Feb 4, 2025
1 parent 41e3c60 commit ac47745
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clients/drcachesim/tests/burst_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void *
# define ALT_STACK_SIZE (SIGSTKSZ * 2)
sigstack.ss_sp = (char *)malloc(ALT_STACK_SIZE);
sigstack.ss_size = ALT_STACK_SIZE;
sigstack.ss_flags = SS_ONSTACK;
sigstack.ss_flags = 0;
int res = sigaltstack(&sigstack, NULL);
assert(res == 0);
#endif
Expand Down
2 changes: 1 addition & 1 deletion suite/tests/api/static_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ thread_func(void *arg)
int rc;
sigstack.ss_sp = (char *)malloc(ALT_STACK_SIZE);
sigstack.ss_size = ALT_STACK_SIZE;
sigstack.ss_flags = SS_ONSTACK;
sigstack.ss_flags = 0;
rc = sigaltstack(&sigstack, NULL);
ASSERT_NOERR(rc);
signal_cond_var(thread_ready);
Expand Down
2 changes: 1 addition & 1 deletion suite/tests/linux/bad-signal-stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ main(int argc, char *argv[])
/* Make an alternate stack that's not writable. */
sigstack.ss_sp = alloc;
sigstack.ss_size = ALT_STACK_SIZE;
sigstack.ss_flags = SS_ONSTACK;
sigstack.ss_flags = 0;
rc = sigaltstack(&sigstack, NULL);
ASSERT_NOERR(rc);
protect_mem((void *)sigstack.ss_sp, ALT_STACK_SIZE, ALLOW_READ);
Expand Down
2 changes: 1 addition & 1 deletion suite/tests/linux/signal-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static void
stack_t sigstack;
sigstack.ss_sp = siginfo; /* will fail: just need sthg */
sigstack.ss_size = ALT_STACK_SIZE;
sigstack.ss_flags = SS_ONSTACK;
sigstack.ss_flags = 0;
int rc = sigaltstack(&sigstack, NULL);
assert(rc == -1 && errno == EPERM);
#endif
Expand Down

0 comments on commit ac47745

Please sign in to comment.