From: Patrick Oppenlander <patrick.oppenlander@gmail.com>
To: musl@lists.openwall.com
Subject: Re: pthread cancel cleanup and pthread_mutex_lock
Date: Wed, 30 May 2018 10:06:17 +1000 [thread overview]
Message-ID: <CAEg67GmfoPSOimj00AQ8LMo3QbYuEeiqzqU-O+uG5zUkcfYxjw@mail.gmail.com> (raw)
In-Reply-To: <CAEg67GkF1+o6HuhTYgu8fmUxpXLXb+OdMTyYxRuPMcWBHW+0DQ@mail.gmail.com>
I accidentally hit send before I finished typing..
> I've recently been running some of the open posix testsuite tests from
> the linux test project.
>
> One particular test has been giving me headaches:
> https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/1-2.c
>
> There are a couple of different tests in there but the most
> interesting one is the deadlock test which does the following:
>
> Thread A: Thread B:
> pthread_create
> pthread_cleanup_push(...)
> pthread_mutex_lock(M)
> pthread_setcanceltype(ASYNC)
> pthread_setcancelstate(ENABLE)
pthread_mutex_lock(M) <-- blocks here
pthread_cancel(B)
pthread_join(B)
The test then expects the cleanup handler to run and unlock mutex M
allowing thread B to run to completion and the join to succeed.
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
I'm not even sure that this test is valid -- I can't find any
documentation which says that pthread_mutex_lock is a cancellation
point, or that you're allowed to call pthread_mutex_unlock from an
async cancel handler.
However, it's still concerning to see different results on different platforms.
What's the expected behaviour here?
Patrick
next prev parent reply other threads:[~2018-05-30 0:06 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 [this message]
2018-05-30 0:50 ` Rich Felker
2018-05-30 1:36 ` Patrick Oppenlander
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=CAEg67GmfoPSOimj00AQ8LMo3QbYuEeiqzqU-O+uG5zUkcfYxjw@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).