public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "triegel at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug nptl/12875] pthread_cond_timedwait can steal the wakeup of slower thread in pthread_cond_wait
Date: Thu, 20 Sep 2012 16:59:00 -0000	[thread overview]
Message-ID: <bug-12875-131-K0wtFauF2z@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-12875-131@http.sourceware.org/bugzilla/>


http://sourceware.org/bugzilla/show_bug.cgi?id=12875

--- Comment #16 from Torvald Riegel <triegel at redhat dot com> 2012-09-20 16:59:10 UTC ---
(In reply to comment #15)
> Created attachment 6639 [details]
> Test case with explicit happens-before logic rather than usleep
> 
> As requested, I've attached a version of the test case that uses the lock,
> barriers and atomic instructions to enforce happens-before.

Thanks.

> This bug may be different from Bug 13165, because it is caused by waking from a
> timeout rather than an extra signal.

Even this happens with cond_timedwait, it seems to me that it is conceptually
the same issue.

> Why I think this is a bug: my reading of the sentence "The
> pthread_cond_signal() function shall unblock at least one of the threads that
> are blocked on the specified condition variable cond (if any threads are
> blocked on cond)." is that it only affects threads that "are blocked" at the
> time pthread_cond_signal() is called, not those that call pthread_cond_wait
> afterwards.

I don't read it that way.  Please see the discussion in bug #13165 about this. 
To summarize, the spec only requires the threads to be considered as blocked
that happen before the signal, but it does not require threads that wait after
the signal to NOT be considered blocked.  In your example, the waiter in thread
D is not disallowed to be considered as a blocked thread.

> The wording for pthread_cond_broadcast() says "currently blocked",
> but is that an intentional difference?

I can't speak about the intent of the authors of the spec. A more detailed
specification would certainly be easier to understand.  But unless there is a
change, I would stick to what's allowed/required by the current wording.

OK to classify as not a bug?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


  parent reply	other threads:[~2012-09-20 16:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 17:57 [Bug nptl/12875] New: " martin at lispworks dot com
2011-06-11 13:36 ` [Bug nptl/12875] " drepper.fsp at gmail dot com
2011-06-13 12:39 ` martin at lispworks dot com
2011-09-28 21:55 ` bugdal at aerifal dot cx
2012-03-17 20:41 ` bugdal at aerifal dot cx
2012-04-29  3:01 ` bugdal at aerifal dot cx
2012-09-18 14:18 ` triegel at redhat dot com
2012-09-18 14:28 ` triegel at redhat dot com
2012-09-19  3:21 ` bugdal at aerifal dot cx
2012-09-19  6:24 ` jakub at redhat dot com
2012-09-19  8:22 ` triegel at redhat dot com
2012-09-19  8:24 ` bugdal at aerifal dot cx
2012-09-19  8:50 ` bugdal at aerifal dot cx
2012-09-19 15:35 ` triegel at redhat dot com
2012-09-19 17:30 ` bugdal at aerifal dot cx
2012-09-20 12:29 ` triegel at redhat dot com
2012-09-20 14:02 ` martin at lispworks dot com
2012-09-20 16:59 ` triegel at redhat dot com [this message]
2012-09-21  8:05 ` siddhesh at redhat dot com
2014-06-24  8:36 ` fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-12875-131-K0wtFauF2z@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).