https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121495

            Bug ID: 121495
           Summary: [14/15/16 regression] lld miscompiled since
                    r14-6290-g9f0f7d802482a8
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: needs-reduction, wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Created attachment 62098
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62098&action=edit
SyntheticSections.cpp.ii.xz

Originally reported downstream in Gentoo at https://bugs.gentoo.org/958469.

lld crashes with GCC 14 on arm64 at -O2 since r14-6290-g9f0f7d802482a8:
```
$ touch a.o
$ /root/data/build/llvm-project-lld/bin/ld.lld -EL -m aarch64linux -shared -o
b.so --gdb-index a.o
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and
include the crash backtrace.
Stack dump:
0.      Program arguments: /root/data/build/llvm-project-lld/bin/ld.lld -EL -m
aarch64linux -shared -o b.so --gdb-index a.o
malloc(): corrupted top size
Aborted (core dumped)
```

Backtrace:
```
Program received signal SIGSEGV, Segmentation fault.
0x0000fffff7e51360 in llvm::SmallVectorBase<unsigned int>::SmallVectorBase
(this=<optimized out>, FirstEl=<optimized out>, TotalCapacity=0)
    at /usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:63
63        SmallVectorBase(void *FirstEl, size_t TotalCapacity)
(gdb) bt
#0  0x0000fffff7e51360 in llvm::SmallVectorBase<unsigned int>::SmallVectorBase
(this=<optimized out>, FirstEl=<optimized out>, TotalCapacity=0)
    at /usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:63
#1  llvm::SmallVectorTemplateCommon<lld::elf::GdbIndexSection::GdbSymbol,
void>::SmallVectorTemplateCommon (this=<optimized out>, Size=0)
    at /usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:135
#2  llvm::SmallVectorTemplateBase<lld::elf::GdbIndexSection::GdbSymbol,
false>::SmallVectorTemplateBase (this=<optimized out>, Size=0)
    at /usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:336
#3 
llvm::SmallVectorImpl<lld::elf::GdbIndexSection::GdbSymbol>::SmallVectorImpl
(this=<optimized out>, N=0) at
/usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:588
#4  llvm::SmallVector<lld::elf::GdbIndexSection::GdbSymbol, 0u>::SmallVector
(this=<optimized out>) at /usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:1198
#5  std::make_unique<llvm::SmallVector<lld::elf::GdbIndexSection::GdbSymbol,
0u> []> (__num=32) at
/usr/lib/gcc/aarch64-unknown-linux-gnu/14/include/g++-v14/bits/unique_ptr.h:1092
#6  createSymbols (ctx=..., nameAttrs=..., chunks=...) at
/root/git/llvm-project-20.1.7.src/lld/ELF/SyntheticSections.cpp:3505
#7  0x0000fffff7e77848 in
lld::elf::GdbIndexSection::create<llvm::object::ELFType<(llvm::endianness)1,
true> > (ctx=...) at /usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:78
#8  0x0000fffff7e7914c in
lld::elf::createSyntheticSections<llvm::object::ELFType<(llvm::endianness)1,
true> > (ctx=...)
    at /root/git/llvm-project-20.1.7.src/lld/ELF/SyntheticSections.cpp:4958
#9  0x0000fffff7d32a1c in
lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, true> >
(this=this@entry=0xaaaaaab38f48, args=...)
    at /root/git/llvm-project-20.1.7.src/lld/ELF/Driver.cpp:3205
#10 0x0000fffff7d38a64 in lld::elf::LinkerDriver::linkerMain
(this=0xaaaaaab38f48, argsArr=...) at
/root/git/llvm-project-20.1.7.src/lld/ELF/Driver.cpp:672
#11 0x0000fffff7d39260 in lld::elf::link (args=..., stdoutOS=..., stderrOS=...,
exitEarly=<optimized out>, disableOutput=<optimized out>)
    at /root/git/llvm-project-20.1.7.src/lld/ELF/Driver.cpp:142
#12 0x0000fffff77eee90 in lld::unsafeLldMain (args=..., stdoutOS=...,
stderrOS=..., drivers=..., exitEarly=exitEarly@entry=true) at
/usr/lib/llvm/20/include/llvm/ADT/SmallVector.h:78
#13 0x0000aaaaaaaa32d4 in lld_main (argc=<optimized out>, argv=<optimized out>)
at /root/git/llvm-project-20.1.7.src/lld/tools/lld/lld.cpp:90
#14 0x0000aaaaaaaa2a40 in main (argc=<optimized out>, argv=<optimized out>) at
/root/data/build/llvm-project-lld/tools/lld/lld-driver.cpp:17
```

Reply via email to