Skip to content

[X86][MC] Crash when assembling file containing section with 64-bit alignment #34074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
llvmbot opened this issue Sep 26, 2017 · 4 comments
Closed
Labels
bugzilla Issues migrated from bugzilla llvm:asmparser mc Machine (object) code

Comments

@llvmbot
Copy link
Member

llvmbot commented Sep 26, 2017

Bugzilla Link 34726
Version trunk
OS All
Blocks #11360
Reporter LLVM Bugzilla Contributor
CC @topperc,@RKSimon,@rotateright

Extended Description

the clang assembler crashes when passed the attached assembly
file which contains the following lines:

        .text
        .align 0x100000000, 0x90
        mov     %rax,%rbx
        .data
        .align 0x200000000, 0x90
        mov     %rsi, %rdi
$ clang -c source1.s
clang-6.0: /llvm/include/llvm/Support/MathExtras.h:678: uint64_t llvm::alignTo(uint64_t, uint64_t, uint64_t): Assertion `Align != 0u && "Align can't be 0."' failed.
#0 0x0000000003bbf9bf llvm::sys::PrintStackTrace(llvm::raw_ostream&) /llvm/lib/Support/Unix/Signals.inc:398:0
#1 0x0000000003bbfa52 PrintStackTraceSignalHandler(void*) /llvm/lib/Support/Unix/Signals.inc:462:0
#2 0x0000000003bbdc2d llvm::sys::RunSignalHandlers() /llvm/lib/Support/Signals.cpp:49:0
#3 0x0000000003bbf22b SignalHandler(int) /llvm/lib/Support/Unix/Signals.inc:252:0
#4 0x00007f3073987390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#5 0x00007f30726f2428 gsignal /build/glibc-bfm8X4/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
#6 0x00007f30726f402a abort /build/glibc-bfm8X4/glibc-2.23/stdlib/abort.c:91:0
#7 0x00007f30726eabd7 __assert_fail_base /build/glibc-bfm8X4/glibc-2.23/assert/assert.c:92:0
#8 0x00007f30726eac82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#9 0x0000000001ae5441 llvm::alignTo(unsigned long, unsigned long, unsigned long) /llvm/include/llvm/Support/MathExtras.h:679:0
#10 0x00000000020d4e07 llvm::OffsetToAlignment(unsigned long, unsigned long) /llvm/include/llvm/Support/MathExtras.h:720:0
#11 0x0000000003782555 llvm::MCAssembler::computeFragmentSize(llvm::MCAsmLayout const&, llvm::MCFragment const&) const /data/projects/BUGS/38096/llvm/lib/MC/MCAssembler.cpp:292:0
#12 0x0000000003782bad llvm::MCAsmLayout::layoutFragment(llvm::MCFragment*) /llvm/lib/MC/MCAssembler.cpp:362:0
#13 0x00000000037bc5bc llvm::MCAsmLayout::ensureValid(llvm::MCFragment const*) const /llvm/lib/MC/MCFragment.cpp:73:0
#14 0x00000000037bc607 llvm::MCAsmLayout::getFragmentOffset(llvm::MCFragment const*) const /llvm/lib/MC/MCFragment.cpp:79:0
#15 0x00000000037859bd llvm::MCAssembler::finishLayout(llvm::MCAsmLayout&) /llvm/lib/MC/MCAssembler.cpp:955:0
#16 0x0000000003784411 llvm::MCAssembler::layout(llvm::MCAsmLayout&) /llvm/lib/MC/MCAssembler.cpp:704:0
#17 0x00000000037849d1 llvm::MCAssembler::Finish() /llvm/lib/MC/MCAssembler.cpp:755:0
#18 0x00000000037d0f54 llvm::MCObjectStreamer::FinishImpl() /llvm/lib/MC/MCObjectStreamer.cpp:608:0
#19 0x00000000037b3bcd llvm::MCELFStreamer::FinishImpl() /llvm/lib/MC/MCELFStreamer.cpp:621:0
#20 0x00000000037d9aac llvm::MCStreamer::Finish() /llvm/lib/MC/MCStreamer.cpp:748:0
#21 0x0000000003805208 (anonymous namespace)::AsmParser::Run(bool, bool) /llvm/lib/MC/MCParser/AsmParser.cpp:961:0
#22 0x0000000001ac966f ExecuteAssembler((anonymous namespace)::AssemblerInvocation&, clang::DiagnosticsEngine&) /llvm/tools/clang/tools/driver/cc1as_main.cpp:453:0
#23 0x0000000001ac9e28 cc1as_main(llvm::ArrayRef<char const*>, char const*, void*) /llvm/tools/clang/tools/driver/cc1as_main.cpp:534:0
#24 0x0000000001ab5346 ExecuteCC1Tool(llvm::ArrayRef<char const*>, llvm::StringRef) /llvm/tools/clang/tools/driver/driver.cpp:304:0
#25 0x0000000001ab5ec1 main /llvm/tools/clang/tools/driver/driver.cpp:381:0
#26 0x00007f30726dd830 __libc_start_main /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:325:0
#27 0x0000000001ab2939 _start (/llvm-build/r313400/bin/clang-6.0+0x1ab2939)
Stack dump:
0.      Program arguments: /llvm-build/r313400/bin/clang-6.0 -cc1as -triple x86_64-unknown-linux-gnu -filetype obj -main-file-name source1.s -target-cpu x86-64 -fdebug-compilation-dir /70046 -dwarf-debug-producer clang version 6.0.0 (trunk 313400) -dwarf-version=4 -mrelocation-model static -o source1.o source1.s
clang-6.0: error: unable to execute command: Aborted (core dumped)
clang-6.0: error: clang integrated assembler command failed due to signal (use -v to see invocation)
clang version 6.0.0 (trunk 313400)

This is reproducible on all clang versions.

@llvmbot
Copy link
Member Author

llvmbot commented Nov 29, 2017

Fix posted for review:
https://reviews.llvm.org/D38302

@llvmbot
Copy link
Member Author

llvmbot commented Nov 30, 2017

Funny, I did the same and was going to publish the fix just now. OK, go forward but next time take the assignment and check it before you're going to do anything.

@llvmbot
Copy link
Member Author

llvmbot commented Nov 30, 2017

I assigned the bug for myself posted the fix on Sep 26 2017.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@MaskRay
Copy link
Member

MaskRay commented May 13, 2023

An alignment larger than 2**32 isn't used or needed in practice. Many tools will bail out. ld.lld doesn't support such a large alignment to make InputSection smalleer.

Looks like I simply rejected such a large alignment in 01d1de8 (2020), fixing the crash.

@MaskRay MaskRay closed this as completed May 13, 2023
@EugeneZelenko EugeneZelenko added llvm:asmparser mc Machine (object) code and removed backend:X86 labels May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:asmparser mc Machine (object) code
Projects
None yet
Development

No branches or pull requests

3 participants