From: Zack Weinberg <zackw@panix.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2 02/21] nptl: Fix testcases for new pthread cancellation mechanism
Date: Tue, 8 May 2018 09:35:11 -0400 [thread overview]
Message-ID: <CAKCAbMgnO_p-P37_67MuQDLqhtTQLGud2bo-MUzvdq+yBnu8fw@mail.gmail.com> (raw)
In-Reply-To: <de85508a-5689-91f4-a1c3-f39c724fd225@linaro.org>
On Mon, May 7, 2018 at 1:13 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> On 06/05/2018 23:49, Zack Weinberg wrote:
>> On 26 Feb 2018, Adhemerval Zanella wrote:
>>> For tst-cancel{2,3} case it remove the pipe close because it might
>>> cause the write syscall to return with side effects if the close is
>>> executed before the pthread cancel.
>>
>> ... however, this change appears to be wrong. If cancellation is
>> broken, these tests will now deadlock rather than failing cleanly.
>
> On current cancellation implementation the thread will finish regardless
> and sigcancel_handler will act whether there is side-effects or not
> (the pipe close). The issue is cancellation should not happen if syscall
> returns but some side effects already took place, in this case the pipe
> close.
I think maybe I didn't explain clearly enough what I'm worried about
here. What the test case does _when cancellation works_ is sensible.
But this is a test case, it also needs to behave sensibly when
cancellation _doesn't_ work. Imagine a new port where, for some
reason, the cancellation mechanism is so broken that read/write aren't
acting as cancellation points at all. Without the close,
tst-cancel{2,3} will block forever in read/write. We have the
test-driver timeout as a backstop, but we shouldn't rely on it.
> Yes, although for this specific case I am not sure if this could happen
> in practice. I assume if a thread issues a 'signal' followed by a 'close',
> the signal target thread will receive the events in a ordered manner, i.e,
> the signal handler will be activated before the syscall sees any
> side-effects (the close). It seems to be Linux behaviour, but I am not
> sure if a different system might act differently.
I don't think POSIX makes any requirements, but yes, in practice the
signal should always arrive first.
> And I try to avoid the timing check, such as pthread_timedjoin_np,
> because they tend to quite fragile in practice for such cases (due either
> to system load when testing glibc, machine performance, etc.).
This is reasonable.
For the new cancellation mechanism in general, we don't have a good
way of arranging for SIGCANCEL to arrive at exactly the critical
points within the syscall sequence, do we? I am tempted to try to
write a test case that scripts gdb and single-steps through a call to
open() and fires SIGCANCEL at each instruction.
>> won't it? I think teaching the backtrace logic about this would be
>> better than needing to use a raw syscall() and then mess with the
>> PowerPC implementation of syscall(). I might feel differently about
>> this change if __read_nocancel were a public API, but it isn't...
>
> With your current suggestion to powerpc syscall bits, there is no need
> to actually change the powerpc syscall implementation besides an
> additional CFI mechanism. But I do not mind to change the testcase on
> the bz12683 fix itself, the only advantage I see is by using indirect
> syscall there is no need to actually change it again.
I don't feel especially strongly about this now we have a way that
doesn't add actual instructions to powerpc syscall().
zw
next prev parent reply other threads:[~2018-05-08 13:35 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-26 21:03 [PATCH v2 00/21] nptl: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 01/21] powerpc: Create stackframe information on syscall Adhemerval Zanella
2018-02-26 21:41 ` Andreas Schwab
2018-02-27 12:05 ` Adhemerval Zanella
2018-05-07 2:49 ` Zack Weinberg
2018-05-07 13:57 ` Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 02/21] nptl: Fix testcases for new pthread cancellation mechanism Adhemerval Zanella
2018-02-26 21:43 ` Andreas Schwab
2018-02-27 12:05 ` Adhemerval Zanella
2018-05-07 2:49 ` Zack Weinberg
2018-05-07 17:13 ` Adhemerval Zanella
2018-05-08 13:35 ` Zack Weinberg [this message]
2018-05-08 17:26 ` Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 03/21] nptl: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella
2018-04-27 12:20 ` Zack Weinberg
2018-04-27 12:25 ` Adhemerval Zanella
2018-05-07 2:48 ` Zack Weinberg
2018-05-07 2:49 ` Zack Weinberg
2018-05-08 17:11 ` Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 04/21] nptl: x86_64: " Adhemerval Zanella
2018-05-07 2:49 ` Zack Weinberg
2018-05-08 17:55 ` Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 05/21] nptl: x32: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 06/21] nptl: i386: " Adhemerval Zanella
2018-05-07 2:49 ` Zack Weinberg
2018-05-08 17:56 ` Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 07/21] nptl: powerpc: " Adhemerval Zanella
2018-05-07 19:25 ` Tulio Magno Quites Machado Filho
2018-05-08 18:07 ` Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 08/21] nptl: aarch64: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 09/21] nptl: arm: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 10/21] nptl: s390: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 11/21] nptl: ia64: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 12/21] nptl: alpha: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 13/21] nptl: m68k: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 14/21] nptl: microblaze: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 15/21] nptl: tile: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 16/21] nptl: sparc: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 17/21] nptl: nios2: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 18/21] nptl: sh: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 19/21] nptl: mips: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 20/21] nptl: hppa: " Adhemerval Zanella
2018-02-26 21:03 ` [PATCH v2 21/21] nptl: riscv: " Adhemerval Zanella
2018-02-27 1:16 ` DJ Delorie
2018-02-27 13:03 ` Adhemerval Zanella
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
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKCAbMgnO_p-P37_67MuQDLqhtTQLGud2bo-MUzvdq+yBnu8fw@mail.gmail.com \
--to=zackw@panix.com \
--cc=adhemerval.zanella@linaro.org \
--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).