Opened 9 years ago

Closed 9 years ago

#5336 closed bug (fixed)

pthread_mutex_trylock() hangs

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

Change History (5)

comment:1 Changed 9 years ago by bonefish

Confirmed. The pthread_mutex_trylock() implementation is incorrect. It should not even touch the semaphore, but instead use atomic_test_and_set() on the count. Moreover the kernel's thread_block_with_timeout_locked() needs to check for an overflow in case B_TIMEOUT_REAL_TIME_BASE is set.

comment:2 Changed 9 years ago by stippi

I've looked into this problem a bit, but I am not quite sure why the pthread_mutex_trylock() implementation is the problem (also from talking to Axel). I understand that by doing what it does, it potentially converts a benaphore style mutex into a semaphore based one. Is the hanging problem then in the kernel implementation with the 0 absolute timeout? If pthread_mutex_trylock() only touches the count, how would it work when the mutex has alreasy been converted to be semaphore based?

comment:3 Changed 9 years ago by stippi

The WebCore trylock asserts work now (don't hang a WebPositive debug build on start-up anymore). Kaliber, can you please check if this bug is fixed for your test-cases as well?

comment:4 in reply to:  3 Changed 9 years ago by kaliber

Replying to stippi:

The WebCore trylock asserts work now (don't hang a WebPositive debug build on start-up anymore). Kaliber, can you please check if this bug is fixed for your test-cases as well?

Yes, it's fixed.

comment:5 Changed 9 years ago by stippi

Resolution: fixed
Status: newclosed

Nice. Fixed in hrev36323 then.

Note: See TracTickets for help on using tickets.