public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug nptl/12310] pthread_exit() in main thread segfaults when statically-linked
Date: Thu, 23 May 2013 14:02:00 -0000	[thread overview]
Message-ID: <bug-12310-131-BHorYD32Oi@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-12310-131@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=12310

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING
                 CC|                            |carlos at redhat dot com

--- Comment #4 from Carlos O'Donell <carlos at redhat dot com> 2013-05-23 14:02:19 UTC ---
(In reply to comment #3)
> I guess nobody expected static program working with threads but not invoking
> pthread_create() anywhere. So in real cases weak reference doesn't make
> problems
> Obvious solution could be adding reference to __nptl_nthreads in pthread_exit.c

The fact that this doesn't crash in master is sheer luck.

In the non-static case the forwarder calls exit() when you ask for
pthread_exit() and everything works correctly. In the static case you actually
call pthread_exit() and it breaks because nothing included __nptl_nthreads from
pthread_create.os and that means it has a zero value.

Static linking should work for all reasonable cases.

This case is reasonable because the main thread is a real thread and you should
be able to exit from it using pthread_exit.

We need a reference to __nptl_nthreads as you suggest. Doing so will pull in
all of pthread_exit.os into the application image, so it might grow a little in
size. I don't see that as a problem.

Please post a patch to libc-alpha@sourceware.org to fix this.

I suggest building glibc master, and testing the patch with that, and making
sure `make -k check' doesn't show any regressions.

See:
http://sourceware.org/glibc/wiki/Testing/Builds
and
http://sourceware.org/glibc/wiki/Contribution%20checklist

Your change is sufficiently minimal that it probably falls below the legally
significant barrier and doesn't require a copyright assignment. However, if you
plan to contribute more changes then we strongly recommend signing a copyright
assignment for glibc to the FSF (or whatever you want to do e.g. individual
disclaimer).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


  parent reply	other threads:[~2013-05-23 14:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14 12:41 [Bug nptl/12310] New: " mrs@mythic-beasts.com
2012-05-08 17:32 ` [Bug nptl/12310] " siddhesh at redhat dot com
2012-12-19 10:41 ` schwab@linux-m68k.org
2013-05-17 14:14 ` wintersonnenwende at yandex dot ru
2013-05-17 14:29 ` wintersonnenwende at yandex dot ru
2013-05-23 14:02 ` carlos at redhat dot com [this message]
2013-06-16 13:27 ` wintersonnenwende at yandex dot ru
2013-06-17 15:31 ` carlos at redhat dot com
2013-06-22 14:08 ` v.nikulichev at gmail dot com
2013-06-23 14:56 ` v.nikulichev at gmail dot com
2013-06-24 17:24 ` carlos at redhat dot com
2013-06-24 17:25 ` carlos at redhat dot com
2013-06-24 17:57 ` carlos at redhat dot com
2013-06-24 17:57 ` carlos at redhat dot com
2013-06-24 21:12 ` carlos at redhat dot com
2014-06-30  6:20 ` fweimer at redhat dot com

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=bug-12310-131-BHorYD32Oi@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@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).