Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Oct 2008 10:26:20 GMT
From:      Dmitry Moskalchuk <d.moskalchuk@drweb.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   i386/128265: deadlock in pthread_create occurs in case if any C++ exception was thrown and succesfully catched
Message-ID:  <200810211026.m9LAQKER046167@www.freebsd.org>
Resent-Message-ID: <200810211030.m9LAU0vX039657@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         128265
>Category:       i386
>Synopsis:       deadlock in pthread_create occurs in case if any C++ exception was thrown and succesfully catched
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-i386
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 21 10:30:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Moskalchuk
>Release:        7.0-STABLE
>Organization:
DrWeb
>Environment:
FreeBSD freebsd70s.i.drweb.ru 7.0-STABLE FreeBSD 7.0-STABLE #0: Fri Aug 22 22:54:27 MSD 2008     root@freebsd70s.i.drweb.ru:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
There is an error either in the GNU C++ library or in the pthread_create implementation: in case if any C++ exception was thrown and succesfully catched all "pthread_create" calls causes dead-lock.
>How-To-Repeat:
Just build and run the minimal example:

////// test.cpp
#include <iostream>
#include <pthread.h>

void *thread(void *arg)
{
    std::cout << "Thread" << std::endl;
}

void conditional_throw(bool arg)
{
    if(arg)
        throw "Exception";
}

int main(int argc, char *argv[])
{
    std::cout << "Start" << std::endl;

    try { conditional_throw(argc > 1 && ::strcasecmp(argv[1], "freeze") == 0); }
    catch(...) {}

    std::cout << "Create thread" << std::endl;

    pthread_t tid;
    int ret = ::pthread_create(&tid, 0, &thread, 0);
    if(ret != 0)
        return 1;

    ::sleep(1);

    std::cout << "Stop" << std::endl;

    return 0;
}
//// end of test.cpp

You'll need to run it with command-line parameter "freeze" to get deadlock.

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810211026.m9LAQKER046167>