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 |
Attachments (2)
Change History (10)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Updated patch. The previous patch went against the coding guidelines by assigning in an if statement.
follow-up: 4 comment:3 by , 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.
comment:4 by , 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 , 15 years ago
They are now, but in POSIX code we should actually use the POSIX error codes as well.
comment:6 by , 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 , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:8 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Thanks for the patch! I've updated it slightly (and fixed a minor coding style violation) in hrev33775.
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.