From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: DJ Delorie <dj@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v3] i386: Use pthread_barrier for synchronization on tst-bz21269
Date: Tue, 28 Feb 2023 11:29:03 -0300 [thread overview]
Message-ID: <f6036249-d0ed-6306-66fc-b649a871cc3e@linaro.org> (raw)
In-Reply-To: <xnr0ua7nr1.fsf@greed.delorie.com>
On 27/02/23 19:21, DJ Delorie wrote:
> 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?
What I did was to actually revert the original fix and check if the test
in fact trigger the issue:
diff --git a/sysdeps/unix/sysv/linux/i386/libc_sigaction.c b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c
index 0665b41bbc..b2454d8d55 100644
--- a/sysdeps/unix/sysv/linux/i386/libc_sigaction.c
+++ b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c
@@ -33,7 +33,7 @@ extern void restore (void) asm ("__restore") attribute_hidden;
? &restore_rt : &restore); \
} \
else \
- (kact)->sa_restorer = NULL; \
+ (kact)->sa_restorer = (void*)0xdeadbeef; \
})
#define RESET_SA_RESTORER(act, kact) \
And it does not, because as you pointed out the barrier are not fully
correct. So I circle back and I think the v2 is actually correctly,
using a bogus sa_restore does trigger a failure and the test succeeds
with current code.
>
> 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.
>
Alright.
next prev parent reply other threads:[~2023-02-28 14:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 16:15 Adhemerval Zanella
2023-02-27 22:21 ` DJ Delorie
2023-02-28 14:29 ` Adhemerval Zanella Netto [this message]
2023-03-02 5:10 ` DJ Delorie
2023-03-02 17:00 ` Adhemerval Zanella Netto
2023-03-02 20:21 ` DJ Delorie
2023-03-08 18:01 ` Adhemerval Zanella Netto
2023-05-10 21:31 ` DJ Delorie
2023-05-15 18:33 ` Adhemerval Zanella Netto
2023-05-16 19:10 ` DJ Delorie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f6036249-d0ed-6306-66fc-b649a871cc3e@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=dj@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).