[haiku-development] Re: Calling pthread_join on a detached pthread

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 5 Aug 2012 09:54:10 -0400

On 8/5/12, Jason Whitehorn <jason.whitehorn@xxxxxxxxx> wrote:
> In regard's to Bonefish's comment about "leaking memory"; perhaps this is
> just my ignorance, but I am a little confused about not calling free in
> this case would leak memory, as it would appear that it was the call to
> free that was actually crashing.

When pthread_detach() is called, the thread structure associated with
it is freed. As such, if you then call pthread_join() on the same
structure, you're asking the latter to operate on already freed
memory, hence the crash.



Other related posts: