Bug 128912 - pthread_exit linked on RHEL2.1 ia64 crashes on RHEL3
Summary: pthread_exit linked on RHEL2.1 ia64 crashes on RHEL3
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc
Version: 3.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks: 123573
TreeView+ depends on / blocked
 
Reported: 2004-07-31 08:56 UTC by Alexandre Oliva
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-12-13 20:28:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Don't use _Unwind_ForcedUnwind if __libc_csu_init() is not defined (1.28 KB, patch)
2004-07-31 09:38 UTC, Alexandre Oliva
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2004:623 0 normal SHIPPED_LIVE Updated gcc packages 2004-12-13 05:00:00 UTC

Description Alexandre Oliva 2004-07-31 08:56:11 UTC
1) We compiled the program under RHEL 2.1:
Red Hat Linux Advanced Server release 2.1AS (Derry)
Linux rhia202 2.4.18-e.12smp #1 SMP Thu Oct 17 15:13:01 EDT 2002 ia64
unknown
gcc-2.96-116.7.2
libgcc-3.0.4-1
[verified with:
gcc-2.96-128.7.2
libgcc-3.0.4-1
glibc-2.2.4-32.15
binutils-2.11.90.0.8-12.4
-aoliva]

2) Program compiled using:
gcc -pthread t.c -o t -g

3) Program executed on RHEL 3.0
Red Hat Enterprise Linux AS release 3 (Taroon)
Linux inteleverest3 2.4.21-4.EL #1 SMP Fri Oct 3 17:29:39 EDT 2003
ia64 ia64 ia64 GNU/Linux
libgcc-3.2.3-20
[verified with:
libgcc-3.2.3-32
glibc-2.3.2-95.17
-aoliva ]

4) Result:
Program terminated with signal 11, Segmentation fault.
(gdb) where
#0  0x2000000000819a40 in _Unwind_GetBSP () from /lib/libgcc_s.so.1
#1  0x2000000000819de0 in _Unwind_GetBSP () from /lib/libgcc_s.so.1
Previous frame identical to this frame (corrupt stack?)

Here's the program:

#include <stdio.h>
#include <pthread.h>
#include <string.h>
void *thread__func(void *dummy)
{
         pthread_exit(0);
}

int main()
{
         int i=0;
         pthread_t thread;
         pthread_create(&thread, NULL, thread__func, (void *)&i);
         sleep(2);
}

Replacing pthread_exit(0) with return 0, the program does not crash.

Running the program on AS2.1, or on 3EL with Linuxthreads, it doesn't
crash.  Only NPTL crashes, during stack unwinding.

On x86, the program works.

Comment 2 Alexandre Oliva 2004-07-31 09:38:33 UTC
Created attachment 102334 [details]
Don't use _Unwind_ForcedUnwind if __libc_csu_init() is not defined

Although we could fix the problem in the AS2.1 crt1.o, adding unwind info to
its crt1.o, this wouldn't get programs built with the previous crt1.o to work. 
For those, we'd need some work around in the RHEL3 libc.  One symbol defined in
the new crt1.o, but not in older ones, is __libc_csu_init().  Testing for its
presence would be a relatively easy work around for the problem.  However, if
the user chooses to hide this symbol in the main executable, it won't work.

Unfortunately, we can't just add some code to RHEL 3's crt1.o to set a flag in
pthread.so because then older RHEL3 programs would not use _Forced_Unwind.

However, we could use an inclusive combination of these two mechanisms: change
crt1.o to call a function optionally defined in libpthread to get this flag
set, and tweak pthread_init to set this same flag if __libc_csu_init is
defined.  Should I implement this alternate, more complex patch, or is the one
above enough?  Or should we come up with yet another approach?

Comment 3 Jakub Jelinek 2004-07-31 19:55:57 UTC
Actually, this seems to be GCC 2.9x bug.
pthread_exit is __attribute__((noreturn)), and GCC 2.96-RH puts the
br.call.sptk.many b0 = pthread_exit#
instruction as the last instruction in the routine.
This breaks the unwinder, as call insn must not be the last one:
Current ia64.c has in ia64_reorg:
  /* A call must not be the last instruction in a function, so that the
     return address is still within the function, so that unwinding works
     properly.  Note that IA-64 differs from dwarf2 on this point.  */
and inserts a break.f 0 instruction after the call if it is indeed the
last instruction in the routine.
Guess we need to backport it.

Comment 4 Jakub Jelinek 2004-07-31 19:59:38 UTC
Guess the patch in question is:
2001-05-11  Richard Henderson  <rth>

        * config/ia64/ia64.c (group_barrier_needed_p): Don't allow
        calls and jumps to be bundled together.
        (ia64_reorg): Emit a break after a noreturn call that ends
        a function.
        * config/ia64/ia64.md (break_f): New.
http://gcc.gnu.org/ml/gcc-patches/2001-05/msg00672.html

Comment 5 Jakub Jelinek 2004-08-02 13:44:54 UTC
Should be fixed in gcc-2.96-129.7.2 in dist-2.1AS-errata-candidate.
I have uploaded them to
ftp://people.redhat.com/jakub/gcc/errata/2.96-129.7.2/
so that SyBase/MSDW can check it out.

Comment 10 John Flanagan 2004-12-13 20:28:25 UTC
An errata has been issued which should help the problem 
described in this bug report. This report is therefore being 
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, 
please follow the link below. You may reopen this bug report 
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-623.html



Note You need to log in before you can comment on or make changes to this bug.