public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/2748] New: Cancel from printf not calling the cancel handler
@ 2006-06-09 22:10 sjmunroe at us dot ibm dot com
  2006-06-09 22:13 ` [Bug nptl/2748] " sjmunroe at us dot ibm dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2006-06-09 22:10 UTC (permalink / raw)
  To: glibc-bugs

Found this problem debug failure reported by our cluster team. If we are
PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DEFERRED and pthread_cancel is called
while a thread is waiting on a pthread_rwlock the cancelation will be defered
until the threads wakes up (whoever is holding the lock does
pthread_rwlock_unlock(). 

In this case the thread holding the lock is signaled, runs its cancle handler
and unlocks. One of the waiting threads wakes up and calls printf (which is a
cancellation point). We expect printf (vfprintf) to detect that cancellation is
pending and initiate cancel handling (including calling this threads cancel
handler).

Instead we that thread exiting prematurely (from start_thread,
__exit_thread_inline(0). This leave other threads hung waiting on the
pthread_rwlock and the main thread waiting on pthread_join.

-- 
           Summary: Cancel from printf not calling the cancel handler
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: critical
          Priority: P1
         Component: nptl
        AssignedTo: drepper at redhat dot com
        ReportedBy: sjmunroe at us dot ibm dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i568-unknown-linux-gnu, powerpc64-unknown-linux-gnu,
                    powerpc32-u
  GCC host triplet: i568-unknown-linux-gnu, powerpc64-unknown-linux-gnu,
                    powerpc32-u
GCC target triplet: i568-unknown-linux-gnu, powerpc64-unknown-linux-gnu,
                    powerpc32-u


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
@ 2006-06-09 22:13 ` sjmunroe at us dot ibm dot com
  2006-06-09 22:18 ` sjmunroe at us dot ibm dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2006-06-09 22:13 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From sjmunroe at us dot ibm dot com  2006-06-09 22:13 -------
Created an attachment (id=1073)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=1073&action=view)
C++ test case the demonstrats the problem

Compile with:

g++ -g -O0 thct_wrl2.C -lpthread -o thct_wrl2

Run with:

THCT_USE_CANCEL=1 ./thct_wrl2 4

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
  2006-06-09 22:13 ` [Bug nptl/2748] " sjmunroe at us dot ibm dot com
@ 2006-06-09 22:18 ` sjmunroe at us dot ibm dot com
  2006-06-09 22:27 ` sjmunroe at us dot ibm dot com
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2006-06-09 22:18 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From sjmunroe at us dot ibm dot com  2006-06-09 22:18 -------
So far I have verified this failure on the recent GLIBC (cvs from 06/08/2006)
for ia32 (i586), powerpc32 and powerpc64. We dom't see the failure on X86_64. I
don't have access to other platforms at this time.

It don't see failures on any platforms for glibc-2.3.3 or glibc-2.3.4. Have not
looked at 2.3.5 or 2.3.6.

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
  2006-06-09 22:13 ` [Bug nptl/2748] " sjmunroe at us dot ibm dot com
  2006-06-09 22:18 ` sjmunroe at us dot ibm dot com
@ 2006-06-09 22:27 ` sjmunroe at us dot ibm dot com
  2006-06-13 21:45 ` bergner at vnet dot ibm dot com
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2006-06-09 22:27 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From sjmunroe at us dot ibm dot com  2006-06-09 22:27 -------
Looks like we get into vfprintf which calls _pthread_cleanup_pop_restore() which
detects the defered cancellation and we fail into CANCELLATION_P (self). This
ends up calling pthread_unwind which (atleast for powerpc) ends up in the libgcc
unwind code. This where things go badly,

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (2 preceding siblings ...)
  2006-06-09 22:27 ` sjmunroe at us dot ibm dot com
@ 2006-06-13 21:45 ` bergner at vnet dot ibm dot com
  2006-06-13 21:46 ` bergner at vnet dot ibm dot com
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bergner at vnet dot ibm dot com @ 2006-06-13 21:45 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From bergner at vnet dot ibm dot com  2006-06-13 21:45 -------
Created an attachment (id=1085)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=1085&action=view)
A C version of the test case.

Here is a C version of the test case with the problematic source extracted into
its own source file (bug.c).  Compiling bug.c with -fexceptions is all that is
needed to recreate the problem.  This does fail as a 32-bit x86 app as well as
32-bit and 64-bit ppc apps.  With this test case, you no longer need to set the
env var.

  linux% ./thct_wrl2 8

The code we're having problems with from bug.c is:

void thd_thread_2 (unsigned int ndx)
{
  pthread_cleanup_push ((void (*)(void*))thd_cleanup, &ndx);
  thread_body(ndx);
  pthread_cleanup_pop (1);
}

This test case does seem to work with older glibcs (eg, 2.3.4).


-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (3 preceding siblings ...)
  2006-06-13 21:45 ` bergner at vnet dot ibm dot com
@ 2006-06-13 21:46 ` bergner at vnet dot ibm dot com
  2006-08-13  6:38 ` drepper at redhat dot com
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: bergner at vnet dot ibm dot com @ 2006-06-13 21:46 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bergner at vnet dot ibm dot
                   |                            |com


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (4 preceding siblings ...)
  2006-06-13 21:46 ` bergner at vnet dot ibm dot com
@ 2006-08-13  6:38 ` drepper at redhat dot com
  2006-08-13  6:39 ` drepper at redhat dot com
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: drepper at redhat dot com @ 2006-08-13  6:38 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|i568-unknown-linux-gnu,     |
                   |powerpc64-unknown-linux-gnu,|
                   |powerpc32-u                 |


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (5 preceding siblings ...)
  2006-08-13  6:38 ` drepper at redhat dot com
@ 2006-08-13  6:39 ` drepper at redhat dot com
  2006-08-13  6:39 ` drepper at redhat dot com
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: drepper at redhat dot com @ 2006-08-13  6:39 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i568-unknown-linux-gnu,     |
                   |powerpc64-unknown-linux-gnu,|
                   |powerpc32-u                 |


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (6 preceding siblings ...)
  2006-08-13  6:39 ` drepper at redhat dot com
@ 2006-08-13  6:39 ` drepper at redhat dot com
  2007-03-28 16:18 ` jakub at redhat dot com
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: drepper at redhat dot com @ 2006-08-13  6:39 UTC (permalink / raw)
  To: glibc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|i568-unknown-linux-gnu,     |
                   |powerpc64-unknown-linux-gnu,|
                   |powerpc32-u                 |


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (7 preceding siblings ...)
  2006-08-13  6:39 ` drepper at redhat dot com
@ 2007-03-28 16:18 ` jakub at redhat dot com
  2007-03-28 16:19 ` jakub at redhat dot com
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at redhat dot com @ 2007-03-28 16:18 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2007-03-28 17:17 -------
The problem is that many functions don't have .eh_frame unwind info generated.
There are 2 ways how to solve this, one is to build the whole libc with
-fasynchronous-unwind-tables (that's e.g. what Fedora 7 is doing and what e.g.
x86_64 or s390{,x} do by default), or write a patch similar to the one I'll
attach (but while this patch handles just stuff found in the backtrace where this
was cancelled, the real patch would need to investigate what are all callers of
cancellable functions and make sure they are all not __THROW and built with
either -fexceptions of -fasynchronous-unwind-tables.
The important difference between the two is that with -fexceptions you don't get
any unwind info if e.g. all callees are __THROW, with the latter you get it
anyway.
FYI, the testcase is buggy, passing address of an automatic variable as last
pthread_create argument and dereferencing it in the thread body has undefined
behavior.

-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (8 preceding siblings ...)
  2007-03-28 16:18 ` jakub at redhat dot com
@ 2007-03-28 16:19 ` jakub at redhat dot com
  2007-03-29 14:53 ` sjmunroe at us dot ibm dot com
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at redhat dot com @ 2007-03-28 16:19 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2007-03-28 17:19 -------
Created an attachment (id=1654)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=1654&action=view)
glibc-bz2748.patch


-- 


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (9 preceding siblings ...)
  2007-03-28 16:19 ` jakub at redhat dot com
@ 2007-03-29 14:53 ` sjmunroe at us dot ibm dot com
  2008-04-08  1:18 ` drepper at redhat dot com
  2010-06-01  2:26 ` pasky at suse dot cz
  12 siblings, 0 replies; 14+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2007-03-29 14:53 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From sjmunroe at us dot ibm dot com  2007-03-29 15:52 -------
Alan can look at this issue for PPC32/64?

Specifically for missing/incomplete CFI impacting cancel or making
-fasynchronous-unwind-tables the default for powerpc.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amodra at bigpond dot net
                   |                            |dot au


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (10 preceding siblings ...)
  2007-03-29 14:53 ` sjmunroe at us dot ibm dot com
@ 2008-04-08  1:18 ` drepper at redhat dot com
  2010-06-01  2:26 ` pasky at suse dot cz
  12 siblings, 0 replies; 14+ messages in thread
From: drepper at redhat dot com @ 2008-04-08  1:18 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2008-04-08 01:17 -------
I don't see this problem anymore.  Please retest and report.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug nptl/2748] Cancel from printf not calling the cancel handler
  2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
                   ` (11 preceding siblings ...)
  2008-04-08  1:18 ` drepper at redhat dot com
@ 2010-06-01  2:26 ` pasky at suse dot cz
  12 siblings, 0 replies; 14+ messages in thread
From: pasky at suse dot cz @ 2010-06-01  2:26 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From pasky at suse dot cz  2010-06-01 02:26 -------
no response

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |WORKSFORME


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-06-01  2:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-09 22:10 [Bug nptl/2748] New: Cancel from printf not calling the cancel handler sjmunroe at us dot ibm dot com
2006-06-09 22:13 ` [Bug nptl/2748] " sjmunroe at us dot ibm dot com
2006-06-09 22:18 ` sjmunroe at us dot ibm dot com
2006-06-09 22:27 ` sjmunroe at us dot ibm dot com
2006-06-13 21:45 ` bergner at vnet dot ibm dot com
2006-06-13 21:46 ` bergner at vnet dot ibm dot com
2006-08-13  6:38 ` drepper at redhat dot com
2006-08-13  6:39 ` drepper at redhat dot com
2006-08-13  6:39 ` drepper at redhat dot com
2007-03-28 16:18 ` jakub at redhat dot com
2007-03-28 16:19 ` jakub at redhat dot com
2007-03-29 14:53 ` sjmunroe at us dot ibm dot com
2008-04-08  1:18 ` drepper at redhat dot com
2010-06-01  2:26 ` pasky at suse dot cz

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).