public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dan at censornet dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug nptl/12683] Race conditions in pthread cancellation
Date: Thu, 15 Jan 2015 13:20:00 -0000	[thread overview]
Message-ID: <bug-12683-131-KYlT0ZICF4@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-12683-131@http.sourceware.org/bugzilla/>

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

Dan Searle <dan at censornet dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dan at censornet dot com

--- Comment #25 from Dan Searle <dan at censornet dot com> ---
I think we have stubmled upon this bug, or something related to it. Can someone
please confirm I'm on the right track here?

We have a multithreaded server application which calls recv() and poll() from
async cancellable threads, each thread handles a single connection with a
master thread accpeting new connections and adding them to a job queue.

More and more often now we are seeing the server lock up and on inspection two
or more threads seem deadlocked in some race condition inside libc recv() and
or poll().

One example here shows two back traces from gdb from the two threads that
seemed deadlocked chewing 100% CPU:

Thread 1 bt:
#0  __pthread_disable_asynccancel () at
../nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S:98
#1  0x00007f895ba987fd in __libc_recv (fd=0, fd@entry=33,
buf=buf@entry=0x7cada02b, n=n@entry=1024, flags=1537837035,
    flags@entry=16384) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:35
#2  0x000000000040ec54 in recv (__flags=16384, __n=1024, __buf=0x7cada02b,
__fd=33)
    at /usr/include/x86_64-linux-gnu/bits/socket2.h:44
[snip]

Thread 2 bt:
#0  0x00007f895ba987eb in __libc_recv (fd=fd@entry=31,
buf=buf@entry=0x7ca5e02b, n=n@entry=1024, flags=-1, flags@entry=16384)
    at ../sysdeps/unix/sysv/linux/x86_64/recv.c:33
#1  0x000000000040ec54 in recv (__flags=16384, __n=1024, __buf=0x7ca5e02b,
__fd=31)
    at /usr/include/x86_64-linux-gnu/bits/socket2.h:44
[snip]

There can be more than two threads involved, but I'm unsure if it can happen
with just one thread locked up, but it's always inside recv() or poll() and
sometimes in __pthread_disable_asynccancel() within either of those.

Could I work around this problem by changing the threads to syncronmous
cancellable or try to work around the need to cancel the treads at all?

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


  parent reply	other threads:[~2015-01-15 13:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-18 22:28 [Bug nptl/12683] New: " bugdal at aerifal dot cx
2011-04-18 22:35 ` [Bug nptl/12683] " bugdal at aerifal dot cx
2011-09-21 18:30 ` bugdal at aerifal dot cx
2012-04-29  2:56 ` bugdal at aerifal dot cx
2012-04-29  2:57 ` bugdal at aerifal dot cx
2012-09-22 23:13 ` bugdal at aerifal dot cx
2013-08-16 15:32 ` carlos at redhat dot com
2013-08-16 15:34 ` carlos at redhat dot com
2013-08-16 15:34 ` carlos at redhat dot com
2013-08-16 16:22 ` bugdal at aerifal dot cx
2013-08-16 16:59 ` carlos at redhat dot com
2013-08-16 17:14 ` bugdal at aerifal dot cx
2013-08-16 18:09 ` carlos at redhat dot com
2014-01-10 20:25 ` carlos at redhat dot com
2014-01-10 21:31 ` carlos at redhat dot com
2014-01-10 22:37 ` bugdal at aerifal dot cx
2014-01-12 18:31 ` carlos at redhat dot com
2014-01-12 23:55 ` bugdal at aerifal dot cx
2014-01-13  1:52 ` carlos at redhat dot com
2014-01-13  4:37 ` bugdal at aerifal dot cx
2014-01-14 14:51 ` carlos at redhat dot com
2014-02-16 19:42 ` jackie.rosen at hushmail dot com
2014-05-28 19:47 ` schwab at sourceware dot org
2014-05-28 19:47 ` schwab at sourceware dot org
2014-06-27 13:35 ` fweimer at redhat dot com
2014-07-19 18:44 ` sstewartgallus00 at mylangara dot bc.ca
2014-07-19 18:54 ` bugdal at aerifal dot cx
2014-07-20 18:15 ` sstewartgallus00 at mylangara dot bc.ca
2014-07-20 18:41 ` bugdal at aerifal dot cx
2014-08-19 14:08 ` azanella at linux dot vnet.ibm.com
2014-08-28 15:02 ` carlos at redhat dot com
2015-01-15 13:20 ` dan at censornet dot com [this message]
2015-01-15 13:31 ` bugdal at aerifal dot cx
2015-01-15 14:01 ` dan at censornet dot com
2020-06-08 14:04 ` 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-12683-131-KYlT0ZICF4@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).