[LLVMbugs] [Bug 7268] New: Convoluted code-generation bug leading to segfault

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 31 04:35:47 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7268

           Summary: Convoluted code-generation bug leading to segfault
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jbytheway+llvm at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=4953)
 --> (http://llvm.org/bugs/attachment.cgi?id=4953)
Source and makefile to reproduce the bug

This bug is rather involved.  The crux of the matter seems to be a segfault
that happens at runtime in the atomic operations used to support
boost::shared_ptr.  However, in order to make the bug manifest I need a fair
bit of quite random-seeming other code around it.

I don't know whether this is a clang or llvm issue at heart, but I encountered
it through clang, so I'm filing it there.

I'm running Gentoo GNU/Linux on amd64.  The code uses both standard library and
Boost headers.  I'm using the gcc 4.4.3 standard library, and Boost 1.42
(headers suffice; the Boost libraries are not necessary, and I doubt the
particular code in use has changed significantly in recent Boost versions).  If
preprocessed source code would be more useful I can certainly provide that.

I'm using llvm and clang trunk, revision 105219.

I attach a tarball that demonstrates the bug.  I did my best to cut it down to
a minimal example, but it's still quite messy.  Here's the behaviour I see:

$ make test
clang -O3 -c -o main.o main.cpp
clang -O3 -c -o other.o other.cpp
clang -o exe main.o other.o -lstdc++
./exe
make: *** [test] Segmentation fault

The code doesn't do anything except copy objects around, but of course in the
case of shared_ptrs that's non-trivial.

Note in particular, all of the following are necessary to make the bug
manifest:
- The two source files must be compiled to objects separately and then linked,
not compiled directly together into an executable.
- Optimization must be turned on (level 2 or above suffices).
- Many seemingly-irrelevant details of the various structs defined in
other.hpp.

If I run it in gdb then I get:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400b84 in CF::~CF() ()

and the instruction at that address is:

0x0000000000400b84 <_ZN2CFD2Ev+36>:     lock xadd %eax,0x8(%r14)

which I believe is an atomic operation of some kind, and presume must be out of
boost::shared_ptr somewhere.

Let me know if I can provide any more useful information.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list