[haiku-bugs] Re: [Haiku] #8836: pthread_join on a detached pthread crashes

  • From: "bonefish" <trac@xxxxxxxxxxxx>
  • Date: Sun, 05 Aug 2012 10:58:36 -0000

#8836: pthread_join on a detached pthread crashes
----------------------------+----------------------------
   Reporter:  0x0dev        |      Owner:  nobody
       Type:  bug           |     Status:  closed
   Priority:  normal        |  Milestone:  R1
  Component:  System/POSIX  |    Version:  R1/Development
 Resolution:  invalid       |   Keywords:
 Blocked By:                |   Blocking:
Has a Patch:  1             |   Platform:  All
----------------------------+----------------------------
Changes (by bonefish):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 The specs are pretty explicit about calling `pthread_join()` on detached
 threads:
   "The behavior is undefined if the value specified by the thread argument
 to pthread_join() does not refer to a joinable thread."
 So, crashing is absolutely acceptable behavior. I also don't see how it
 can be avoided without leaking memory (or larger changes). The memory for
 the pthread handle is freed when a detached thread terminates, so any
 pthread function (including `pthread_join()`) using it afterwards will
 access invalid memory. Or IOW code that does anything with the handle of a
 detached pthread is broken.

 Closing the ticket as invalid.

 PS: Regarding your patch, please peruse our coding style guidelines. Your
 patch contains three violations (space after "if", testing "&" results
 with "=="/"!=", double semicolon).

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/8836#comment:4>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: