Skip to content

Commit

Permalink
Give the thread a chance to actually enter the futex
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno authored and rocallahan committed Dec 14, 2024
1 parent 8a55a4f commit 7087278
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/test/x86/deferred_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static void *do_thread(void*) {
test_assert(1 == read(pipefds2[0], &byte, 1));
test_assert(1 == write(pipefds[1], &byte, 1));
futex_wait(2);
test_assert(futex == 3);
return NULL;
}

Expand Down Expand Up @@ -136,11 +137,12 @@ int main(void) {
// Wait for SIGUSR1
test_assert(1 == write(pipefds2[1], &byte, 1));
futex_wait(1);

// Issue SIGUSR2 in thread to let it out of the futex (and let it patch the syscall)
sched_yield(); sched_yield();
pthread_kill(t, SIGUSR2);
pthread_join(t, NULL);

test_assert(futex == 3);

// Make sure that the patching actually happened (if the syscallbuf is enabled)
uintptr_t ret = deferred_patch_syscall(SYS_rrcall_check_presence, RRCALL_CHECK_SYSCALLBUF_USED_OR_DISABLED, 0, 0, 0);
test_assert(ret == (uintptr_t)-ENOSYS || ret == 0);
Expand Down

0 comments on commit 7087278

Please sign in to comment.