[PATCH v3] i386: Use pthread_barrier for synchronization on tst-bz21269
DJ Delorie
dj@redhat.com
Mon Feb 27 22:21:54 GMT 2023
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> static void *
> threadproc (void *ctx)
> {
> - while (1)
> + for (int i = 0; i < NITER; i++)
Ok.
> - futex ((int *) &ftx, FUTEX_WAIT, 1, NULL, NULL, 0);
> - while (atomic_load (&ftx) != 2)
> - {
> - if (atomic_load (&ftx) >= 3)
> - return NULL;
> - }
> + xpthread_barrier_wait (&barrier);
- parent up to this point has set up the LDT
block 1 - thread waits for parent;
> /* clear LDT entry 0. */
> const struct user_desc desc = { 0 };
> xmodify_ldt (1, &desc, sizeof (desc));
>
> - /* If ftx == 2, set it to zero, If ftx == 100, quit. */
> - if (atomic_fetch_add (&ftx, -2) != 2)
> - return NULL;
> + /* Wait for 'ss' set in main thread. */
> + xpthread_barrier_wait (&barrier);
block 2 - child sets ldt, parent does nothing
- post, parent sets SS. This still isn't doing what the original test
case was doing.
The original code did this:
Parent changes LDT and sets SS
- force a task switch, which should segfault
- sigaction's handler either works, or fails <-- important part
- child resets LDT
Do you have a version of libc newer than the patch in BZ#21269 that you
can test the modified test against, to make sure it still detects the
failing case?
Thinking about it, I suspect this change shouldn't be done:
> - TEST_VERIFY_EXIT (sigaction (sig, &sa, 0) == 0);
> + xsigaction (sig, &sa, 0);
Although they do the same things, since it's sigaction we're actually
testing here, hiding it in an xfunction isn't appropriate.
More information about the Libc-alpha
mailing list