C++ runtime abort: internal error: static object destruction

I have a very simple program that dies immediately with this error:

$ ./dtor
C++ runtime abort: internal error: static object marked for destruction more than once
Aborted (core dumped)

There are two orthogonal ways to make the error go away.

  1. don’t link ‘libnoop.so’ into ‘dtor’
  2. comment out ‘std::ostringstream ss’ in main.cxx

Here is the source and makefile.

main.cxx:

#include <sstream>
int main() { std::ostringstream ss; }

Makefile:

dtor: main.o libnoop.so
        pgCC -o dtor main.o ./libnoop.so

main.o: main.cxx
        pgCC -c main.cxx

libnoop.so: noop.cxx
        touch noop.cxx
        pgCC -c noop.cxx
        pgCC -shared noop.o -o libnoop.so

While this is a very simple test case, the bug itself is causing all my applications to die immediately in this manner.

-bryan

Bryan -

Building an executable that references our libstd.so is a little tricky.
I modified your makefile and was able to execute a “hello world” version
of your test case like this:

pgCC -c -shared main.cxx
touch noop.cxx
pgCC -c -shared noop.cxx
pgCC -shared noop.o -o libnoop.so
pgCC -o dtor -Bdynamic main.o ./libnoop.so -L/usr/pgi/linux86-64/6.2-4/libso

before executing dtor, you’ll need:

setenv LD_LIBRARY_PATH /usr/pgi/linux86-64/6.2-4/libso:$LD_LIBRARY_PATH

Thanks Deborah,

I found another, apparently more robust way to make the problem go away: compile and link with the ‘-fpic’ flag. This appears to alleviate the need to set LD_LIBRARY_PATH at runtime.

-bryan