Opened 15 years ago

Closed 15 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:
Platform: All

Description

Attachments (2)

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

Download all attachments as: .zip

Change History (10)

comment:1 by v, 15 years ago

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.

by v, 15 years ago

Attachment: haiku_ticket4828.diff added

updated patch

comment:2 by v, 15 years ago

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

comment:3 by kaliber, 15 years ago

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.

in reply to:  3 comment:4 by anevilyak, 15 years ago

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 by axeld, 15 years ago

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

by v, 15 years ago

Attachment: haiku_ticket4828_try2.diff added

patch with posix error codes

comment:6 by v, 15 years ago

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 by axeld, 15 years ago

Owner: changed from nobody to axeld
Status: newassigned

comment:8 by axeld, 15 years ago

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.