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

            Bug ID: 58056
           Summary: ld segfaults when "-undefined dynamic_lookup" is set
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: freget at googlemail dot com

Created attachment 30588
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30588&action=edit
Object file causing the error

I'm using g++ 4.8.1 on OS X with the following configuration:

Ziel: x86_64-apple-darwin12.4.0
Konfiguriert mit: ../configure --build=x86_64-apple-darwin12.4.0
--prefix=/usr/local/Cellar/gcc48/4.8.1/gcc
--datarootdir=/usr/local/Cellar/gcc48/4.8.1/share
--bindir=/usr/local/Cellar/gcc48/4.8.1/bin
--enable-languages=c,c++,fortran,java,objc,obj-c++ --program-suffix=-4.8
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-cloog=/usr/local/opt/cloog
--with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes
--enable-stage1-checking --enable-checking=release --enable-lto
--disable-werror --enable-plugin
--with-ecj-jar=/usr/local/opt/ecj/share/java/ecj.jar --disable-multilib
Thread-Modell: posix
gcc-Version 4.8.1 (GCC) 

Using the (faulty) object file attached, the following call causes a segfault: 

> g++-4.8   -std=c++0x -g -dynamiclib  -undefined dynamic_lookup -o 
> output.dylib Notifications.cpp.o 
collect2: Fehler: ld mit Signal 11 [Segmentation fault: 11] beendet

However, once I link without "-undefined dynamic_lookup", I get a meaningful
error description:

> g++-4.8 -std=c++0x -g -dynamiclib   -o output.dylib Notifications.cpp.o 
Undefined symbols for architecture x86_64:
  "libsoda::(anonymous namespace)::CustomOutputBuffer::~CustomOutputBuffer()",
referenced from:
      libsoda::(anonymous namespace)::CustomWarnBuffer::~CustomWarnBuffer() in
Notifications.cpp.o
      libsoda::(anonymous namespace)::CustomErrBuffer::~CustomErrBuffer() in
Notifications.cpp.o
      libsoda::(anonymous namespace)::CustomPrintBuffer::~CustomPrintBuffer()
in Notifications.cpp.o
  "vtable for libsoda::(anonymous namespace)::CustomOutputBuffer", referenced
from:
      libsoda::(anonymous
namespace)::CustomOutputBuffer::CustomOutputBuffer(unsigned long) in
Notifications.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member
function has no definition.
  "_elog_finish", referenced from:
      libsoda::(anonymous namespace)::CustomPrintBuffer::printToUser(char*) in
Notifications.cpp.o
      libsoda::(anonymous namespace)::CustomErrBuffer::printToUser(char*) in
Notifications.cpp.o
      libsoda::(anonymous namespace)::CustomWarnBuffer::printToUser(char*) in
Notifications.cpp.o
      libsoda::(anonymous namespace)::DefaultHandler(char const*, char const*,
char const*, int) in Notifications.cpp.o
  "_elog_start", referenced from:
      libsoda::(anonymous namespace)::CustomPrintBuffer::printToUser(char*) in
Notifications.cpp.o
      libsoda::(anonymous namespace)::CustomErrBuffer::printToUser(char*) in
Notifications.cpp.o
      libsoda::(anonymous namespace)::CustomWarnBuffer::printToUser(char*) in
Notifications.cpp.o
      libsoda::(anonymous namespace)::DefaultHandler(char const*, char const*,
char const*, int) in Notifications.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: Fehler: ld gab 1 als Ende-Status zurück

This is something I can work with. Debugging with the only output beeing a
segfault is not that easy. 
Not that the example above was stripped down as much as possible and will never
compile successfully in this configuration.

Reply via email to