[LLVMbugs] [Bug 14731] New: gold plugin crashes with invalid free() when llvm if built with --enable-shared --enable-expensive-checks

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Dec 28 04:43:02 PST 2012


             Bug #: 14731
           Summary: gold plugin crashes with invalid free() when llvm if
                    built with --enable-shared --enable-expensive-checks
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: gold-plugin
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: ambrop7 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 9765
  --> http://llvm.org/bugs/attachment.cgi?id=9765
gdb debugging session with some notes

On Linux, if llvm is built using the autotools toolchain with --enable-shared
--enable-expensive-checks, the gold plugin will crash the linker
unconditionally (all of the above three conditions are necessary). The
following commands will reproduce the problem on Ubuntu 12.04 64-bit. Bug is
also reproducible on Gentoo Linux ~amd64.

As root:
# apt-get build-dep llvm

As non-root:
$ cd $HOME
$ apt-get source binutils
$ svn co https://llvm.org/svn/llvm-project/llvm/trunk llvm
$ cd llvm
$ CC=gcc CXX=g++ CFLAGS="-O0 -g" CXXFLAGS="-O0 -g" ./configure
--prefix=$HOME/llvm-install --enable-shared --enable-expensive-checks
--with-binutils-include=$HOME/binutils-2.22/include --enable-bindings=none
$ make install

Create a dummy object file to be linked. It does not need to be correct.
$ echo dummy > test.o

Now try to link it with gold and the llvm gold plugin:
$ LD_LIBRARY_PATH=$HOME/llvm-install/lib:$LD_LIBRARY_PATH ld.gold -plugin
$HOME/llvm-install/lib/LLVMgold.so test.o

This results in a crash, after the input file has been found to be incorrect.
The same crash happens if the input and link command are correct (at a
different place, but for the same reason). See the attached file for details
(yes, it's reproducable by plain running it outside of gdb, and also with
valgrind which prints an error about the invalid free).

LLVM-3.2 is also affected; I do not know about LLVM-3.1.

I have tried compiling llvm with different compilers (gcc 4.5.2, gcc 4.6.3, gcc
4.7.2, clang 3.0, clang 3.2) and linkers (bfd and gold), but the bug is still
happening. Again, please note this is not something very specific to my
configuration; it can be easily reproduced on Ubuntu 12.04 64-bit, and probably
any other non-ancient Linux distro (maybe needs to be 64-bit).

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