From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: Rich Felker <dalias@libc.org>, Simon <simonhf@gmail.com>
Subject: Re: [musl] Bug report: Reproduction of seg fault caused by musl thread creation race condition
Date: Mon, 27 Jan 2020 21:37:59 +0100 [thread overview]
Message-ID: <20200127203759.GS23985@port70.net> (raw)
In-Reply-To: <CABkUXbe6-vg+A5--2jPJCn4QMJ1HTtt4bdL0S7DQv9nvotwj9A@mail.gmail.com>
* Simon <simonhf@gmail.com> [2020-01-27 11:59:24 -0800]:
> > Upon successful completion, pthread_create() shall store the ID
> >
>
> "Upon successfully completion" is somewhat vague wording IMO which could
> result in misinterpretation? You seem to have interpreted it as "Upon
> function completion", but surely if clone() succeeds, and the new thread
> starts running, then there is already "successful completion" even before
> pthread_create() has returned to caller?
there is no ambiguity here.
completion of a function call, such as pthread_create,
is well defined and it's the point that's sequenced
after the call returns, you have to synchronize with
that point to read the value from another thread.
> This seems more specific than "Upon successful completion" but still
> doesn't exactly tie down whether the thread ID should be written before the
the point is to not tie the behaviour down so you cannot
rely on it, this allows implementation freedom.
> I checked the glibc pthread_create() implementation and it appears to set
> the thread ID before the new thread executes. So from that POV any code
> using glibc relying on this is arguably non-portable, but not racy since
> there is no race with the glibc implementation?
it is racy because glibc gives no guarantee, i.e. an
update may change this implementation internal detail.
next prev parent reply other threads:[~2020-01-27 20:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-27 0:33 Simon
2020-01-27 5:28 ` Markus Wichmann
2020-01-27 17:51 ` Rich Felker
2020-01-27 19:59 ` Simon
2020-01-27 20:37 ` Szabolcs Nagy [this message]
2020-01-27 20:46 ` Rich Felker
2020-02-03 21:14 ` [musl] Why does musl printf() use so much more stack than other implementations when printf()ing floating point numbers? Simon
2020-02-03 21:57 ` Rich Felker
2020-02-03 23:05 ` Szabolcs Nagy
2020-02-03 23:52 ` Szabolcs Nagy
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=20200127203759.GS23985@port70.net \
--to=nsz@port70.net \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=simonhf@gmail.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).