[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Thread: memory leak when using not detached thread?
From: |
Anrdas Vass |
Subject: |
Re: Thread: memory leak when using not detached thread? |
Date: |
Sun, 15 Dec 2002 00:09:16 +0100 |
Yes, but SIGSEGV remains....
A backtrace shows that calling pthread_detach() quickly after
pthread_create() /quickly means less than 10 ms/ dumps core in certain
cases. (glibc-2.2.5)
This small patch seems to help if detach() is called instead of start(). I
don't know what would be the Right Thing (tm) to do, if someone wants to
call detach() to detach a joinable thread.
Perhaps an ost::Thread::sleep(10) call before pthread_detach()?
Index: src/thread.cpp
===================================================================
RCS file: /cvsroot/commoncpp/commoncpp2/src/thread.cpp,v
retrieving revision 1.19
diff -r1.19 thread.cpp
708,716c708,709
< _start = start;
< rtn = pthread_create(&priv->_tid, &priv->_attr,
exec_t(&ccxx_exec_handler), this);
< if(!rtn && priv->_tid)
< {
< pthread_detach(priv->_tid);
< return 0;
< }
< else
< return -1;
---
> pthread_attr_setdetachstate(&priv->_attr, PTHREAD_CREATE_DETACHED);
> return this->start(start);
----- Original Message -----
From: "Federico Montesino Pouzols" <address@hidden>
To: "Vass Andras" <address@hidden>
Cc: <address@hidden>
Sent: Friday, December 13, 2002 12:34 PM
Subject: Re: Thread: memory leak when using not detached thread?
> On Tue, Dec 10, 2002 at 03:16:00PM +0100, Vass Andras wrote:
> > ps: has anynone taken a look at the bug report on savannah.gnu.org?
> >
> Does this problem disappear if you replace start with detach?
>