This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/21291] pthread cancellation fails when contending lock


https://sourceware.org/bugzilla/show_bug.cgi?id=21291

--- Comment #9 from Dimitri Staessens <dimitri.staessens at ugent dot be> ---
I understand the arguments given, and the text can be interpreted the way
Torvald does, but they seem to me against the intent of the POSIX
specification. 

POSIX states "A condition wait (whether timed or not) is a cancellation point."
It doesn't say that passing an expired timeout may lead to undefined behaviour.

To me, the clauses mentioned by Torvald have the intent to allow some leeway in
the implementation when a cancellation request arrives to a suspended thread or
a thread that timeouts, cancellation doesn't necessarily have to happen anymore
at that point and can be deferred. In other words, the implementation can
choose to check the cancellation at any time, else it'd have to check for
cancellation just before returning. But I don't think POSIX has in mind that
there is an execution path in the implementation that doesn't check the
cancellation state at all.

In the current implementation, pthread_cond_timedwait() effectively stops
behaving as a cancellation point if you pass it an expired timeout with the
monotonic clock. This may cause a lot of problems when that cond_timedwait() is
the only cancellation point in the thread, which is what the code example
revealed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]