mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: pthread_getattr_np() vs explicit runtime loader
Date: Sun, 20 Sep 2015 15:41:32 -0400	[thread overview]
Message-ID: <20150920194132.GO17773@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150920193033.GS12087@example.net>

On Sun, Sep 20, 2015 at 09:30:33PM +0200, u-wsnj@aetey.se wrote:
> On Sun, Sep 20, 2015 at 02:27:28PM -0400, Rich Felker wrote:
> > Test program attached. It's just a very basic functionality check.
> 
> Thanks.
> 
> I may be misinterpreting the code but I do not see where it tests
> the condition
> (http://man7.org/linux/man-pages/man3/pthread_getattr_np.3.html)
> "Furthermore, if the stack address attribute was not set in the thread
> attributes object used to create the thread, then the returned thread
> attributes object will report the actual stack address that the
> implementation selected for the thread."
> 
> It seems to be this case which coincides with the crash.

I'm not sure what you mean. Except for the main thread, the t->stack
and t->stack_size fields store the correct values based on what was
used at pthread_create time. The distinct code paths for
caller-provided stack versus implementation-allocated stack already
took place at pthread_create time.

Moreover the case in your program is getting the stack for the main
thread, not for another thread, so the code you're asking about is not
even what's being executed.

> I looked among others at
>  http://www.openwall.com/lists/musl/2013/03/31/5
> and
>  http://git.musl-libc.org/cgit/musl/commit/?id=5db951ef80cae8b627f95b995811bf916c069757
> 
> and still am unsure whether the assumptions hold while using
> the explicit loader.

I don't see anywhere this code has any interacton whatsoever with how
the program was loaded. So I suspect plain old undefined behavior if
the crash depends on how it was loaded.

> > > > gcc? Have you used gdb to get a backtrace and see where the program
> > > > actually crashes?
> > > 
> > > Not yet, going to. Rebuilding gcc with '-g', this takes some time.
> > 
> > Unless gcc is the program crashing I don't see why you need to rebuild
> > gcc with -g...
> 
> These _are_ several of the binaries of gcc-5.x which crash. It looks like
> the ones which crash (java-related ones?) are using pthread_getattr_np()
> while others do not. I did not though consequently check all of them.
> 
> You can easily test this if you have got say a jv-convert binary of
> gcc-5.2.0, dynamically linked with musl and run this binary via the
> explicit loader. Yours and mine environments are different but I would
> not be surprised if the binary crashes for you too.

I might get a chance to look later, but first thought: is jv-convert
using boehm gc? I ask because boehm is one of the main users (iirc) of
pthread_getattr_np and it's full of UB. It's possible that gcc 5 broke
some of the things it's doing, or that they were already broken but
didn't happen to crash before. I think boehm needs some patches to
work safely on musl but maybe not anymore.

Rich


  reply	other threads:[~2015-09-20 19:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-20  6:39 u-wsnj
2015-09-20 16:34 ` Rich Felker
2015-09-20 17:22   ` u-wsnj
2015-09-20 18:27     ` Rich Felker
2015-09-20 19:30       ` u-wsnj
2015-09-20 19:41         ` Rich Felker [this message]
2015-09-21  7:57           ` u-wsnj
2015-09-30 15:43           ` u-uy74
2015-09-30 20:35             ` Update: [musl] " u-uy74
2015-10-06 11:34               ` musl bug or not, real or not? (Was: [musl] Update: [musl] pthread_getattr_np() vs explicit runtime) loader u-uy74
2015-10-06 14:36                 ` Isaac Dunham
2015-10-07  6:48                   ` u-uy74
2015-10-06 17:07                 ` Rich Felker
2015-10-07  7:27                   ` u-uy74
2015-10-07  7:43                     ` Timo Teras
2015-10-07 10:59                       ` u-uy74
2015-10-08 16:48                       ` Rich Felker
2015-10-09  5:39                         ` Timo Teras

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=20150920194132.GO17773@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --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).