public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "michi at triodia dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57975] New: Core dump caused by linking with -lpthread
Date: Wed, 24 Jul 2013 22:37:00 -0000	[thread overview]
Message-ID: <bug-57975-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57975

            Bug ID: 57975
           Summary: Core dump caused by linking with -lpthread
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michi at triodia dot com

The following code works as expected when compiling with

    c++ -g --std=c++11 test.cpp

The program hangs until it is interrupted.

When I compile the same code with

    c++ -g --std=c++11 test.cpp -lpthread

I get a segfault in wait():

Program received signal SIGSEGV, Segmentation fault.
__pthread_mutex_unlock_usercnt (mutex=0x0, decr=0) at pthread_mutex_unlock.c:37
37    pthread_mutex_unlock.c: No such file or directory.
(gdb) bt
#0  __pthread_mutex_unlock_usercnt (mutex=0x0, decr=0) at
pthread_mutex_unlock.c:37
#1  0x00007ffff7bc8c17 in pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:94
#2  0x00007ffff79698ec in
std::condition_variable::wait(std::unique_lock<std::mutex>&) ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x0000000000400a69 in main () at test.cpp:13

Here is the complete source:

#include <condition_variable>
#include <mutex>

int main(int, char**)
{
    bool predicate = false;
    std::mutex mutex;
    std::condition_variable condvar;

    std::unique_lock<decltype(mutex)> lock;
    while (!predicate)
    {
        condvar.wait(lock);
    }
}

Compiler version is

    gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3

running on Ubuntu Raring.

libpthread is:

    libpthread.so.0 (libc6,x86-64, OS ABI: Linux 2.6.24) =>
/lib/x86_64-linux-gnu/libpthread.so.0


             reply	other threads:[~2013-07-24 22:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24 22:37 michi at triodia dot com [this message]
2013-07-24 22:38 ` [Bug c++/57975] " michi at triodia dot com
2013-07-24 23:07 ` paolo.carlini at oracle dot com
2013-07-24 23:23 ` [Bug libstdc++/57975] " redi at gcc dot gnu.org
2013-07-24 23:30 ` redi at gcc dot gnu.org
2013-07-24 23:36 ` paolo.carlini at oracle dot com
2013-07-24 23:37 ` redi at gcc dot gnu.org
2013-07-25  0:25 ` michi at triodia 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-57975-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).