#20 Segfault at Thread::detach

Common_Libraries
closed
Library (32)
5
2006-06-11
2006-05-09
Anonymous
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.

Does 'priv' suddenly become unavailable or something
after pthread_create returns? The thread is (obviously)
created in a detached state. Perhaps the executing
thread has already exited by the time the calling
thread gets to test priv->foobar?

Please advise.

Jim Vanns

Discussion

  • David Sugar

    David Sugar - 2006-05-25

    Logged In: YES
    user_id=217

    It is certainly possible the detached thread does indeed
    exit first before the thread calling it's creation has had a
    chance to continue. If it does, it will certainly kill priv
    as it exits. It is probably sufficient to look at the rtn
    from pthread_create, and not bother with also examining
    priv->_tid after detach for additional confirmation. In the
    future, I think I will remove the additional test.

     
  • David Sugar

    David Sugar - 2006-05-25
    • assigned_to: nobody --> dyfet
     
  • David Sugar

    David Sugar - 2006-06-11
    • status: open --> closed
    • labels: 732998 --> Library
     

Log in to post a comment.