Opened 10 years ago

Closed 10 years ago

#4828 closed bug (fixed)

Crash in pthread_detach (double free)

Reported by: kaliber Owned by: axeld
Priority: normal Milestone: R1
Component: System/POSIX Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Attachments (2)

haiku_ticket4828.diff (618 bytes) - added by v 10 years ago.
updated patch
haiku_ticket4828_try2.diff (1.5 KB) - added by v 10 years ago.
patch with posix error codes

Download all attachments as: .zip

Change History (10)

comment:1 Changed 10 years ago by v

Seems like a silly thing to do, calling pthread_detach() after pthread_join(), but if it's a valid action perhaps attached patch is an acceptable solution.
I'd be inclined to return B_BAD_VALUE for a thread that has already been detached, but that doesn't agree with the testcase.

The patch has not been compiled or tested.
I couldn't find any POSIX doc that agreed or disagreed with the testcase, but I haven't looked very hard.

Changed 10 years ago by v

Attachment: haiku_ticket4828.diff added

updated patch

comment:2 Changed 10 years ago by v

Updated patch. The previous patch went against the coding guidelines by assigning in an if statement.

comment:3 Changed 10 years ago by kaliber

According to specification http://www.opengroup.org/onlinepubs/000095399/functions/pthread_detach.html function should return 0 instead of B_OK and EINVAL instead of B_BAD_VALUE.

comment:4 in reply to:  3 Changed 10 years ago by anevilyak

Replying to kaliber:

According to specification http://www.opengroup.org/onlinepubs/000095399/functions/pthread_detach.html function should return 0 instead of B_OK and EINVAL instead of B_BAD_VALUE.

Which are precisely the values B_OK and B_BAD_VALUE map to.

comment:5 Changed 10 years ago by axeld

They are now, but in POSIX code we should actually use the POSIX error codes as well.

Changed 10 years ago by v

Attachment: haiku_ticket4828_try2.diff added

patch with posix error codes

comment:6 Changed 10 years ago by v

How about haiku_ticket4828_try2.diff then? All BeOS/Haiku style error codes in pthread.c are replaced by the POSIX versions (as far as I can see). In addition to modifications to pthread_detach().

comment:7 Changed 10 years ago by axeld

Owner: changed from nobody to axeld
Status: newassigned

comment:8 Changed 10 years ago by axeld

Resolution: fixed
Status: assignedclosed

Thanks for the patch! I've updated it slightly (and fixed a minor coding style violation) in hrev33775.

Note: See TracTickets for help on using tickets.