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

  • From: Ryan Leavengood <leavengood@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 5 Aug 2012 10:45:20 -0400

On Sun, Aug 5, 2012 at 10:21 AM, Jason Whitehorn
<jason.whitehorn@xxxxxxxxx> wrote:
>
> The patch I submitted prevented the crash, and resulted in this
> particular test case to pass.

Since the code in your patch accesses the same freed thread structure
to check the flags which makes the later free crash, the fact that it
fixed the test case is just luck, since apparently the freed memory
isn't written over before you try to access it again.

> Perhaps this test suite is outdated as well... that is part of what I am
> trying to understand.

Certainly the test suite isn't correct for Haiku at least since a
detached thread is freed, so it doesn't make sense to check the flags
of a freed thread. There may be a better way to fix this to at least
avoid the crash, though I would tend to side with Ingo that sometimes
crashes are better in cases like this since they more obviously show
incorrect program code than returning EINVAL, which he caller may not
even check.

-- 
Regards,
Ryan

Other related posts: