llvm / llvm/llvm-project

[lld] crash when including a linker script with an unterminated assignment longer than 28 characters

Open
#190,376 2 comments 0 reactions 1 assignee Claimed by @MaskRay View on GitHub
crash lld:ELF
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

While using rustc with a linker script that included another linker script I observed a crash. I am not sure if this is fully LLVM related or rustc is somehow to blame for this, but nightly did not fix anything.

I made repository with the necessary files to reproduce the crash: https://github.com/sleepycatcoding/llvm_lld_crash

Backtrace:
```
= note: terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: rust-lld -flavor gnu /target/aarch64-unknown-none-softfloat/debug/deps/rustc2zBwsn/symbols.o /target/aarch64-unknown-none-softfloat/debug/deps/example-6ebd317ab9074860.dge6hmcy9dq78ttvsaoq28vxj.1sp4mff.rcgu.o --as-needed -Bstatic /toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-none-softfloat/lib/libcore-cf1cc63e92ba364b.rlib /toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-none-softfloat/lib/libcompiler_builtins-dccbebd6b4765f89.rlib -L /target/aarch64-unknown-none-softfloat/debug/deps/rustc2zBwsn/raw-dylibs -Bdynamic --eh-frame-hdr -z noexecstack -o /target/aarch64-unknown-none-softfloat/debug/deps/example-6ebd317ab9074860 --gc-sections --library-path= --script=script.ld
#0 0x00007f0329957bd7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x5f57bd7)
#1 0x00007f03299584cd SignalHandler(int, siginfo_t*, void*) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x5f584cd)
#2 0x00007f0323645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#3 0x00007f032369eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x00007f032369eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#5 0x00007f032369eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#6 0x00007f032364527e raise ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007f03236288ff abort ./stdlib/abort.c:81:7
#8 0x00007f03297e66e5 __gnu_cxx::__verbose_terminate_handler() (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x5de66e5)
#9 0x00007f03297e5e46 __cxxabiv1::__terminate(void (*)()) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x5de5e46)
#10 0x00007f03297e5eb1 (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x5de5eb1)
#11 0x00007f03297e6005 (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x5de6005)
#12 0x00007f03280b7677 std::__throw_length_error(char const*) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x46b7677)
#13 0x00007f032cf147ad (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/libLLVM.so.22.1-rust-1.96.0-nightly+0x95147ad)
#14 0x000060bb699d2763 (anonymous namespace)::ScriptParser::readAssignment(llvm::StringRef) ScriptParser.cpp:0:0
#15 0x000060bb699ce2b3 lld::elf::readLinkerScript(lld::elf::Ctx&, llvm::MemoryBufferRef) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld+0x4f92b3)
#16 0x000060bb69834ba5 lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef) Driver.cpp:0:0
#17 0x000060bb6983337e lld::elf::link(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld+0x35e37e)
#18 0x000060bb69739165 lld::unsafeLldMain(llvm::ArrayRef, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef, bool) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld+0x264165)
#19 0x000060bb69738290 lld_main(int, char**, llvm::ToolContext const&) (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld+0x263290)
#20 0x000060bb69738901 main (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld+0x263901)
#21 0x00007f032362a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#22 0x00007f032362a28b call_init ./csu/../csu/libc-start.c:128:20
#23 0x00007f032362a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#24 0x000060bb695bb1e9 _start (/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/rust-lld+0xe61e9)

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.