Menu

Thread Problem Corrected?

Help
2001-09-13
2001-09-18
  • Louai Adhami

    Louai Adhami - 2001-09-13

    Hi,
    I've had a problem with a thread that crash systematically as it exited. It seems it does so when it tries to notify its parent of its exit.
    So I changed the code in thread.cpp from

    if ( ... && th->_parent )
      th->_parent->Notify(...)

    to

    if ( ... && th->_parent->isThread() )
      th->_parent->Notify(...)

    I'm not sure why a pointer was used instead of a boolean in the first place.

    Anyway it works for me but I'm not sure I fully understand what's happening.

    Did anyone go through the same problem? Any ideas?
    Thanks.

     
    • Adam Fanello

      Adam Fanello - 2001-09-14

      Just off hand, I'd say that the th->_parent test was there to make sure that you don't dereference a null-pointer on the next line. In that case, your change will cause a segmentation violation instead.

      If your changed seemed to help, then you ought to -add- the new condition to the end of the if, rather than replacing the old one.

      BTW: Don't forget to mention a platform. The code is different on Win32 vs Posix.

       
      • Louai Adhami

        Louai Adhami - 2001-09-18

        You're definetly right about the null-pointer, took that for guranted. Thanks for the reminder.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.