public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/59788] Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH
  2014-01-13 14:15 [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH ro at gcc dot gnu.org
@ 2014-01-13 14:15 ` ro at gcc dot gnu.org
  2014-01-15 12:48 ` ro at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2014-01-13 14:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-01-13
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1

--- Comment #1 from Rainer Orth <ro at gcc dot gnu.org> ---
Mine, patch in progress.


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

* [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH
@ 2014-01-13 14:15 ro at gcc dot gnu.org
  2014-01-13 14:15 ` [Bug target/59788] " ro at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2014-01-13 14:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788

            Bug ID: 59788
           Summary: Mixing libc and libgcc_s unwinders on 64-bit Solaris
                    10+/x86 breaks EH
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: ro at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
              Host: i386-pc-solaris2.1[01]
            Target: i386-pc-solaris2.1[01]
             Build: i386-pc-solaris2.1[01]

I've received a few reports in private mail that exception handling on 64-bit
Solaris 10+/x86 is broken when linking with -Bdirect.

The following testcase shows this:

$ cat unwind-direct.cc
#include <stdexcept>

int
main(void)
{
  try
    { throw std::runtime_error( "Catch me if you can!"); }
  catch(...)
    { return 0; }
  return 1;
}
$ g++ -Wl,-Bdirect -m64 -o unwind-direct unwind-direct.cc
$ ./unwind-direct
terminate called after throwing an instance of 'std::runtime_error'
Segmentation Fault (core dumped)

Investigating this with LD_DEBUG=bindings, one finds

$ LD_DEBUG=bindings ./unwind-direct 2>&1 | grep Unwind
03243: 1: binding
file=../../../i386-pc-solaris2.11/amd64/libstdc++-v3/src/.libs/libstdc++.so.6
to file=/lib/64/libc.so.1: symbol '_Unwind_RaiseException'
03243: 1: binding
file=../../../i386-pc-solaris2.11/amd64/libstdc++-v3/src/.libs/libstdc++.so.6
to file=/lib/64/libc.so.1: symbol '_Unwind_GetLanguageSpecificData'
03243: 1: binding
file=../../../i386-pc-solaris2.11/amd64/libstdc++-v3/src/.libs/libstdc++.so.6
to file=/lib/64/libc.so.1: symbol '_Unwind_GetRegionStart'
03243: 1: binding
file=../../../i386-pc-solaris2.11/amd64/libstdc++-v3/src/.libs/libstdc++.so.6
to file=../../amd64/libgcc_s.so.1: symbol '_Unwind_GetIPInfo'
03243: 1: binding
file=../../../i386-pc-solaris2.11/amd64/libstdc++-v3/src/.libs/libstdc++.so.6
to file=../../amd64/libgcc_s.so.1: symbol '_Unwind_Resume_or_Rethrow'
03243: 1: binding file=../../amd64/libgcc_s.so.1 to file=/lib/64/libc.so.1:
symbol '_Unwind_RaiseException'

The problem is that the amd64 Solaris 10+ libc contains an implementation of
the amd64 unwinder, as prescribed by the amd64 ABI, but only those functions
that are listed there.  libgcc_s contains some more, and both implementations
use different internal datastructures, so mixing them wreaks havoc.

This problem has been seen several times during gcc development when it
affected
gcc runtime libraries.

I'm working on a patch to avoid this once and for all by forcing all gcc-built
executables to bind to the unwinder in libgcc_s.

  Rainer


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

* [Bug target/59788] Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH
  2014-01-13 14:15 [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH ro at gcc dot gnu.org
  2014-01-13 14:15 ` [Bug target/59788] " ro at gcc dot gnu.org
@ 2014-01-15 12:48 ` ro at gcc dot gnu.org
  2014-01-17 14:22 ` ro at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2014-01-15 12:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788

--- Comment #2 from Rainer Orth <ro at gcc dot gnu.org> ---
Created attachment 31843
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31843&action=edit
initial patch

The attached initial patch works fine and fixes the testcase from the PR, but
is
unacceptable as is.

Initially, I attempted to force direct binding to the libgcc_s unwinder by
linking
with a special mapfile if linking with -lgcc_s.  This doesn't work since
libtool
builds shared libraries with -shared -nostdlib, adding -lgcc_s itself.

The second attempt (attached) instead uses that mapfile when -shared is passed.
When libtool adds -lgcc_s -lc -lgcc_s itself, it usually `optimizes' this into
-lc -lgcc_s.  When direct binding is in effect due to the mapfile, we achieve 
exactly what this patch intends to avoid, namely binding to the partial
unwinder
in amd64 libc.  This can be avoided by patching libtool to disable this
optimization
on *solaris2*, which this patch does.

While this works fine for the gcc runtime libraries, as can be observed with 
elfdump -y, gcc 4.9 cannot be released with this patch included: even if the
libtool (ltmain.sh actually) patch were accepted upstream, every package built
with libtool will contain an old copy without that change, causing the breakage
this patch is designed to avoid.  While the optimization can be avoided by
invoking libtool with --preserve-dup-deps, this seem unacceptable, as would
requiring users to run libtoolize from a hypothetical new libtool release with
the ltmain.sh patch.


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

* [Bug target/59788] Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH
  2014-01-13 14:15 [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH ro at gcc dot gnu.org
  2014-01-13 14:15 ` [Bug target/59788] " ro at gcc dot gnu.org
  2014-01-15 12:48 ` ro at gcc dot gnu.org
@ 2014-01-17 14:22 ` ro at gcc dot gnu.org
  2014-02-04  9:32 ` ro at gcc dot gnu.org
  2014-02-04  9:33 ` ro at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2014-01-17 14:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                URL|                            |http://gcc.gnu.org/ml/gcc-p
                   |                            |atches/2014-01/msg01088.htm
                   |                            |l

--- Comment #3 from Rainer Orth <ro at gcc dot gnu.org> ---
Patch submitted.


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

* [Bug target/59788] Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH
  2014-01-13 14:15 [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH ro at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2014-01-17 14:22 ` ro at gcc dot gnu.org
@ 2014-02-04  9:32 ` ro at gcc dot gnu.org
  2014-02-04  9:33 ` ro at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2014-02-04  9:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788

--- Comment #4 from Rainer Orth <ro at gcc dot gnu.org> ---
Author: ro
Date: Tue Feb  4 09:31:38 2014
New Revision: 207454

URL: http://gcc.gnu.org/viewcvs?rev=207454&root=gcc&view=rev
Log:
Ensure libgcc_s unwinder is always used on 64-bit Solaris 10+/x86 (PR
target/59788)

    gcc:
    PR target/59788
    * config/sol2.h (LINK_LIBGCC_MAPFILE_SPEC): Define.
    (LINK_SPEC): Use it for -shared, -shared-libgcc.

    libgcc:
    PR target/59788
    * config/t-slibgcc-sld (libgcc-unwind.map): New target.
    (install-libgcc-unwind-map-forbuild): New target.
    (all): Depend on install-libgcc-unwind-map-forbuild.
    (install-libgcc-unwind-map): New target.
    (install): Depend on install-libgcc-unwind-map.

    gcc/testsuite:
    PR target/59788
    * g++.dg/eh/unwind-direct.C: New test.

    toplevel:
    PR target/59788
    * ltmain.sh (opt_duplicate_compiler_generated_deps): Enable on
    *solaris2*.

Added:
    trunk/gcc/testsuite/g++.dg/eh/unwind-direct.C
Modified:
    trunk/ChangeLog
    trunk/gcc/ChangeLog
    trunk/gcc/config/sol2.h
    trunk/gcc/testsuite/ChangeLog
    trunk/libgcc/ChangeLog
    trunk/libgcc/config/t-slibgcc-sld
    trunk/ltmain.sh


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

* [Bug target/59788] Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH
  2014-01-13 14:15 [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH ro at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2014-02-04  9:32 ` ro at gcc dot gnu.org
@ 2014-02-04  9:33 ` ro at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ro at gcc dot gnu.org @ 2014-02-04  9:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Rainer Orth <ro at gcc dot gnu.org> ---
Fixed for 4.9.0.


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

end of thread, other threads:[~2014-02-04  9:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-13 14:15 [Bug target/59788] New: Mixing libc and libgcc_s unwinders on 64-bit Solaris 10+/x86 breaks EH ro at gcc dot gnu.org
2014-01-13 14:15 ` [Bug target/59788] " ro at gcc dot gnu.org
2014-01-15 12:48 ` ro at gcc dot gnu.org
2014-01-17 14:22 ` ro at gcc dot gnu.org
2014-02-04  9:32 ` ro at gcc dot gnu.org
2014-02-04  9:33 ` ro at gcc dot gnu.org

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