Menu

#221 Segfault at Thread::detach

closed
6
2015-01-12
2006-05-10
James Vanns
No

In the latest version of Common C++ I get a segfault
from said method.

I inherit from PosixThread in a simple class. I create
potentially thousands of threads in the applications
lifetime but each thread only executes for
approximately 10 seconds *max* before exited. However,
after an indetermninate (e.g. sporadic) amount of time
the main (calling) process or thread segfaults here:

#0 ost::Thread::detach (this=0xb4b00470, st=0x0) at
thread.cpp:909
909 if(!rtn && priv->_tid)
(gdb) bt

As gdb shows (this is from a core dump). This happens
in more than one application.

I believe 'priv' becomes unavailable after
pthread_create returns if the thread exits before the
condition can be tested in the calling thread? The
thread is (obviously)
created in a detached state. I have modified the source
on my machine to test for a NULL priv object before
trying to dereference a member belonging to it.
Applications have not crashed since doing this.

Can someone confirm and if necessary fix the bug at the
source? Please advise.

Jim Vanns

Discussion

  • James Vanns

    James Vanns - 2006-05-24

    Logged In: YES
    user_id=1458877

    Anyone even going to respond to this? As I said, I *think*
    I've fixed it by testing the priv object for a NULL value.

    Jim

     
  • David Sugar

    David Sugar - 2007-01-24
    • priority: 5 --> 6
    • assigned_to: nobody --> dyfet
    • status: open --> closed-fixed
     
  • David Sugar

    David Sugar - 2007-01-24

    Logged In: YES
    user_id=217
    Originator: NO

    I believe this had been resolved in recent releases, as they now return if !priv before doing the priv->_tid test...

     

Log in to post a comment.