Opened 15 years ago

Closed 15 years ago

#4064 closed bug (fixed)

[patch]cond_wait always return EAGAIN with an unitialized pthread_cond_t (pthread_cond.c)

Reported by: oco Owned by: axeld
Priority: normal Milestone: R1
Component: - General Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

cond_wait always return EAGAIN with an unitialized pthread_cond_t (pthread_cond.c). This function is used by pthread_cond_wait and pthread_cond_timedwait.
I discover the problem while trying to compile current ruby trunk (1.9). miniruby (a reduced version of ruby used in the build process) stop while calling pthread_cond_timedwait. The return value is always EAGAIN. I use hrev31395 of haiku.
After looking at the source code, i think we should check the return value of create_sem instead of cond->sem. This is what is in the first patch.
I found similar code in mutex_lock (pthread_mutex.c). Maybe, we should also use atomic_test_and_set to assign cond->sem. This is what is added in the second patch. But, as i am not sure of what i am proposing (i am a newbie with threads), careful revue is needed.

Attachments (2)

pthread_cond.c.alt_1.diff (408 bytes ) - added by oco 15 years ago.
First patch
pthread_cond.c.alt_2.diff (543 bytes ) - added by oco 15 years ago.
Second patch

Download all attachments as: .zip

Change History (3)

by oco, 15 years ago

Attachment: pthread_cond.c.alt_1.diff added

First patch

by oco, 15 years ago

Attachment: pthread_cond.c.alt_2.diff added

Second patch

comment:1 by korli, 15 years ago

Resolution: fixed
Status: newclosed

Applied in hrev33779.

Note: See TracTickets for help on using tickets.