From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
To: musl@lists.openwall.com
Subject: Re: Re: pthread cancel cleanup and pthread_mutex_lock
Date: Wed, 30 May 2018 11:36:55 +1000 [thread overview]
Message-ID: <CAEg67GkST7ccx7oTaPNC7uMJuD8ia1X8HyH692_-_Dyz-PzM=g@mail.gmail.com> (raw)
In-Reply-To: <20180530005009.GM1392@brightrain.aerifal.cx>
On Wed, May 30, 2018 at 10:50 AM, Rich Felker <dalias@libc.org> wrote:
> This test is invalid. pthread_mutex_lock is not async-cancel-safe and
> cannot legally be called while cancel type is async.
I suspected as much.
> FYI something like 50% of the "Open POSIX Test Suite" tests are
> invalid; in the majority of cases they're testing some property after
> undefined behavior has been invoked like here.
Thanks. Do you know of any better tests?
>> I've run this test with musl, glibc and on some different platforms
>> with varying results:
>>
>> x86_64 linux 4.16.11, glibc: test runs to completion
>> x86_64 linux 4.16.11, musl: deadlock (cleanup handler doesn't run)
>> arm linux 4.16.5, musl: test runs to completion
>
> The test is invalid in other ways too, involving races. It attempts to
> use sched_yield to ensure that the test thread enters
> pthread_mutex_lock a second time, but there's no reason to expect that
> to do anything, especially if there are sufficiently many cores (as
> many or more than running threads). I suspect the different behaviors
> come down to just different scheduling properties due to performance
> differences, or something like that. Naively, I would expect the test
> to "work" despite being invalid.
The reason it doesn't "work" (besides being stupid) is because the
cleanup handler isn't invoked while the thread is blocked in the
pthread_mutex_lock call. Should it be in the async cancellation case?
>> What's the expected behaviour here?
>
> Nothing meaningful.
Thanks.
Patrick
prev parent reply other threads:[~2018-05-30 1:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 23:54 Patrick Oppenlander
2018-05-30 0:06 ` Patrick Oppenlander
2018-05-30 0:50 ` Rich Felker
2018-05-30 1:36 ` Patrick Oppenlander [this message]
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='CAEg67GkST7ccx7oTaPNC7uMJuD8ia1X8HyH692_-_Dyz-PzM=g@mail.gmail.com' \
--to=patrick.oppenlander@gmail.com \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).