[llvm-bugs] [Bug 42626] New: lld-link crash when build openssl with LTO

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 15 18:06:20 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42626

            Bug ID: 42626
           Summary: lld-link crash when build openssl with LTO
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: steven.shi at intel.com
                CC: llvm-bugs at lists.llvm.org

Hello,
We met a lld-link crash problem when build 32bits openssl1.0 with LTO in uefi
firmware. We narrow down and figure out a simple test case to reproduce this
problem as blow. Please advise. Thank you!

$ cat main.c
void TlsDriverEntryPoint ()
{
  unsigned char *ret = 0;
  const unsigned char cryptopro_ext[17] = {0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};
  int length =17;
  const char *Source;
  Source  = (void*)cryptopro_ext;
  while (length--) {
    *(ret++) = *(Source++);
  }
}

$ cat memcpy.c
typedef unsigned int size_t;
void *memcpy(void *dest, const void *src, size_t n)
{
  return 0;
}

$ cat makefile
CC_FLAGS=  -Oz -flto -target i686-unknown-windows
CC = /home/jshi19/llvm/llvm-project/releaseinstall/bin/clang
DLINK_FLAGS = /MACHINE:X86 /DLL /ENTRY:TlsDriverEntryPoint
DLINK = /home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link
SLINK_FLAGS =
SLINK = /home/jshi19/llvm/llvm-project/releaseinstall/bin/llvm-lib

build:
        "$(CC)" $(CC_FLAGS) -c -o main.obj  main.c
        "$(CC)" $(CC_FLAGS) -c -o memcpy.obj  memcpy.c
        "$(SLINK)" $(SLINK_FLAGS) /OUT:main.lib main.obj
        "$(SLINK)" $(SLINK_FLAGS) /OUT:memcpy.lib memcpy.obj
        "$(DLINK)" /OUT:f.dll $(DLINK_FLAGS) main.lib  memcpy.lib

$ make
"/home/jshi19/llvm/llvm-project/releaseinstall/bin/clang" -Oz -flto -target
i686-unknown-windows -c -o main.obj  main.c
"/home/jshi19/llvm/llvm-project/releaseinstall/bin/clang" -Oz -flto -target
i686-unknown-windows -c -o memcpy.obj  memcpy.c
"/home/jshi19/llvm/llvm-project/releaseinstall/bin/llvm-lib"  /OUT:main.lib
main.obj
"/home/jshi19/llvm/llvm-project/releaseinstall/bin/llvm-lib"  /OUT:memcpy.lib
memcpy.obj
"/home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link" /OUT:f.dll
/MACHINE:X86 /DLL /ENTRY:TlsDriverEntryPoint  main.lib  memcpy.lib
Stack dump:
0.      Program arguments:
/home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link /OUT:f.dll
/MACHINE:X86 /DLL /ENTRY:TlsDriverEntryPoint main.lib memcpy.lib
#0 0x000055f11ed8585a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/jshi19/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:498:0
#1 0x000055f11ed83684 llvm::sys::RunSignalHandlers()
/home/jshi19/llvm/llvm-project/llvm/lib/Support/Signals.cpp:68:0
#2 0x000055f11ed837c2 SignalHandler(int)
/home/jshi19/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:0
#3 0x00007f172a5f2890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
#4 0x000055f11edd8025 lld::coff::DefinedRegular::getChunk() const
/home/jshi19/llvm/llvm-project/lld/COFF/Symbols.h:176:0
#5 0x000055f11edd8025 operator()
/home/jshi19/llvm/llvm-project/lld/COFF/MarkLive.cpp:46:0
#6 0x000055f11edd8025 lld::coff::markLive(llvm::ArrayRef<lld::coff::Chunk*>)
/home/jshi19/llvm/llvm-project/lld/COFF/MarkLive.cpp:55:0
#7 0x000055f11edb763e std::vector<lld::coff::Chunk*,
std::allocator<lld::coff::Chunk*> >::~vector()
/usr/include/c++/7/bits/stl_vector.h:434:0
#8 0x000055f11edb763e lld::coff::LinkerDriver::link(llvm::ArrayRef<char
const*>) /home/jshi19/llvm/llvm-project/lld/COFF/Driver.cpp:1840:0
#9 0x000055f11edb7d08 lld::coff::link(llvm::ArrayRef<char const*>, bool,
llvm::raw_ostream&) /home/jshi19/llvm/llvm-project/lld/COFF/Driver.cpp:78:0
#10 0x000055f11ecfa044 main
/home/jshi19/llvm/llvm-project/lld/tools/lld/lld.cpp:155:0
#11 0x00007f17290c9b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#12 0x000055f11ed555ba _start
(/home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link+0x25a5ba)
Segmentation fault (core dumped)
makefile:12: recipe for target 'build' failed
make: *** [build] Error 139

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190716/151d6a11/attachment-0001.html>


More information about the llvm-bugs mailing list