llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.81k stars 11.91k forks source link

Internal compiler error when compiling libucontext and other stack switching code on aarch64 #70220

Open rlcamp opened 1 year ago

rlcamp commented 1 year ago

I first hit this when compiling some unrelated stack switching code, and then checked to see if it also affected libucontext, which it does. Steps to reproduce:

fresh install of latest bookworm-based 64-bit raspberry pi OS lite apt install git clang git clone --depth 1 https://github.com/kaniini/libucontext.git cd libucontext make CC=clang

results in:

clang -std=gnu99 -D_BSD_SOURCE -fPIC -DPIC -ggdb3 -O2 -Wall -Iinclude -Iarch/aarch64 -Iarch/common -DEXPORT_UNPREFIXED -c -o arch/aarch64/makecontext.o arch/aarch64/makecontext.c
In file included from arch/aarch64/makecontext.c:15:
In file included from /usr/include/string.h:26:
In file included from /usr/include/aarch64-linux-gnu/bits/libc-header-start.h:33:
/usr/include/features.h:194:3: warning: "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-W#warnings]
warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
  ^
arch/aarch64/makecontext.c:48:7: warning: incompatible pointer types assigning to 'unsigned long *' from 'unsigned long long *' [-Wincompatible-pointer-types]
        regp = &(ucp->uc_mcontext.regs[0]);
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: clang -std=gnu99 -D_BSD_SOURCE -fPIC -DPIC -ggdb3 -O2 -Wall -Iinclude -Iarch/aarch64 -Iarch/common -DEXPORT_UNPREFIXED -c -o arch/aarch64/makecontext.o arch/aarch64/makecontext.c
1.  <eof> parser at end of file
2.  Code generation
3.  Running pass 'Function Pass Manager' on module 'arch/aarch64/makecontext.c'.
4.  Running pass 'AArch64 Assembly Printer' on function '@libucontext_makecontext'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x44)[0x7fb34de4dc]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x70)[0x7fb34dc4b4]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(+0xdcb1c0)[0x7fb340b1c0]
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0x7fbbd507bc]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x132a9f0)[0x7fb396a9f0]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm11raw_ostream5writeEPKcm+0x164)[0x7fb34bb49c]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm9MCContext16createTempSymbolERKNS_5TwineEb+0xb4)[0x7fb4871048]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm9MCContext16createTempSymbolEv+0x3c)[0x7fb48713f0]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm16MCDwarfLineEntry4makeEPNS_10MCStreamerEPNS_9MCSectionE+0x3c)[0x7fb4879ec0]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm16MCObjectStreamer19emitInstructionImplERKNS_6MCInstERKNS_15MCSubtargetInfoE+0x94)[0x7fb4896934]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm16MCObjectStreamer15emitInstructionERKNS_6MCInstERKNS_15MCSubtargetInfoE+0x140)[0x7fb4896858]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x28adf50)[0x7fb4eedf50]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x2767f08)[0x7fb4da7f08]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm10AsmPrinter16emitFunctionBodyEv+0xa10)[0x7fb3c7ef30]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x2764ba4)[0x7fb4da4ba4]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0x140)[0x7fb383122c]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x26c)[0x7fb3614390]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x3c)[0x7fb361af70]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x7b4)[0x7fb3614d98]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsEN4llvm9StringRefEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISK_EE+0xad0)[0x7fba11c680]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(+0x1b06f20)[0x7fba3d6f20]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang8ParseASTERNS_4SemaEbb+0x210)[0x7fb9316f1c]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang14FrontendAction7ExecuteEv+0x80)[0x7fbacd4444]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x328)[0x7fbac47d28]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x218)[0x7fbad47d20]
clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x810)[0x413608]
clang[0x411df4]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(+0x207c5fc)[0x7fba94c5fc]
/lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xcc)[0x7fb340ae94]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x120)[0x7fba94c000]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x2b0)[0x7fba920f50]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x7c)[0x7fba92118c]
/lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0xd8)[0x7fba9350c4]
clang(main+0x23d4)[0x411648]
/lib/aarch64-linux-gnu/libc.so.6(+0x27780)[0x7fb21b7780]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0x7fb21b7858]
clang(_start+0x30)[0x40eef0]
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Debian clang version 14.0.6
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/makecontext-3639f8.c
clang: note: diagnostic msg: /tmp/makecontext-3639f8.sh
clang: note: diagnostic msg: 

********************
make: *** [Makefile:147: arch/aarch64/makecontext.o] Error 139

makecontext-3639f8.c.txt makecontext-3639f8.sh.txt

I also followed the recommended steps in the LLVM bug report workflow which led to the following backend code generator result:

llc arch/aarch64/makecontext.bc
# the above did not crash, so

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: llc arch/aarch64/makecontext.bc
1.  Running pass 'Function Pass Manager' on module 'arch/aarch64/makecontext.bc'.
2.  Running pass 'AArch64 Assembly Printer' on function '@libucontext_makecontext'
 #0 0x0000007fabb9e4dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9e4dc)
 #1 0x0000007fabb9c4b4 llvm::sys::RunSignalHandlers() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9c4b4)
 #2 0x0000007fabb9ea9c (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9ea9c)
 #3 0x0000007fb0fcb7bc (linux-vdso.so.1+0x7bc)
 #4 0x0000007fac02a9f0 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x132a9f0)
 #5 0x0000007fabb7b49c llvm::raw_ostream::write(char const*, unsigned long) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe7b49c)
 #6 0x0000007facf31048 llvm::MCContext::createTempSymbol(llvm::Twine const&, bool) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2231048)
 #7 0x0000007facf313f0 llvm::MCContext::createTempSymbol() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x22313f0)
 #8 0x0000007fac3576e8 llvm::DebugHandlerBase::endInstruction() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16576e8)
 #9 0x0000007fac3400d8 llvm::AsmPrinter::emitFunctionBody() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16400d8)
#10 0x0000007fad464ba4 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2764ba4)
#11 0x0000007fabef122c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x11f122c)
#12 0x0000007fabcd4390 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4390)
#13 0x0000007fabcdaf70 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfdaf70)
#14 0x0000007fabcd4d98 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4d98)
#15 0x000000000041043c main (/usr/lib/llvm-14/bin/llc+0x41043c)
#16 0x0000007faa877780 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#17 0x0000007faa877858 call_init ./csu/../csu/libc-start.c:128:20
#18 0x0000007faa877858 __libc_start_main ./csu/../csu/libc-start.c:347:5
#19 0x000000000040ba70 _start (/usr/lib/llvm-14/bin/llc+0x40ba70)
Segmentation fault

bugpoint -run-llc arch/aarch64/makecontext.bc 
Read input file      : 'arch/aarch64/makecontext.bc'
*** All input ok
Initializing execution environment: Found llc: /usr/lib/llvm-14/bin/llc
Running the code generator to test for a crash: <llc>
Generating reference output from raw program: <llc>
Error running tool:
  /usr/lib/llvm-14/bin/llc -o bugpoint-test-program-be893e8.bc-654f6fd.llc.s bugpoint-test-program-be893e8.bc
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /usr/lib/llvm-14/bin/llc -o bugpoint-test-program-be893e8.bc-654f6fd.llc.s bugpoint-test-program-be893e8.bc
1.  Running pass 'Function Pass Manager' on module 'bugpoint-test-program-be893e8.bc'.
2.  Running pass 'AArch64 Assembly Printer' on function '@libucontext_makecontext'
 #0 0x0000007f92dbe4dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9e4dc)
 #1 0x0000007f92dbc4b4 llvm::sys::RunSignalHandlers() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9c4b4)
 #2 0x0000007f92dbea9c (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9ea9c)
 #3 0x0000007f981e57bc (linux-vdso.so.1+0x7bc)
 #4 0x0000007f9324a9f0 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x132a9f0)
 #5 0x0000007f92d9b49c llvm::raw_ostream::write(char const*, unsigned long) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe7b49c)
 #6 0x0000007f94151048 llvm::MCContext::createTempSymbol(llvm::Twine const&, bool) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2231048)
 #7 0x0000007f941513f0 llvm::MCContext::createTempSymbol() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x22313f0)
 #8 0x0000007f935776e8 llvm::DebugHandlerBase::endInstruction() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16576e8)
 #9 0x0000007f935600d8 llvm::AsmPrinter::emitFunctionBody() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16400d8)
#10 0x0000007f94684ba4 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2764ba4)
#11 0x0000007f9311122c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x11f122c)
#12 0x0000007f92ef4390 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4390)
#13 0x0000007f92efaf70 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfdaf70)
#14 0x0000007f92ef4d98 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4d98)
#15 0x000000000041043c main (/usr/lib/llvm-14/bin/llc+0x41043c)
#16 0x0000007f91a97780 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#17 0x0000007f91a97858 call_init ./csu/../csu/libc-start.c:128:20
#18 0x0000007f91a97858 __libc_start_main ./csu/../csu/libc-start.c:347:5
#19 0x000000000040ba70 _start (/usr/lib/llvm-14/bin/llc+0x40ba70)
*** Debugging code generator crash!

*** Attempting to reduce the number of function attributes in the testcase
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc>
<llc>
<llc>
<llc><crash>
<llc><crash>
<llc><crash>
<llc>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc>
<llc>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc>
<llc>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
<llc><crash>
Checking for crash with changing conditionals to always jump to true:          ... <49 total>: <llc><crash>
Emitted bitcode to 'bugpoint-reduced-conditionals.bc'
Checking for crash with only these blocks:          ... <49 total>: <llc><crash>
Emitted bitcode to 'bugpoint-reduced-blocks.bc'
Checking for crash with CFG simplifying:          ... <49 total>: <llc><crash>
Emitted bitcode to 'bugpoint-reduced-simplifycfg.bc'
Checking for crash with only 249 instructions: <llc><crash>
Checking for crash with only 125 instructions: <llc><crash>
Checking for crash with only 63 instructions: <llc>
Checking for crash with only 62 instructions: <llc>
Checking for crash with only 94 instructions: <llc>
Checking for crash with only 31 instructions: <llc>
Checking for crash with only 110 instructions: <llc>
Checking for crash with only 15 instructions: <llc>
Checking for crash with only 118 instructions: <llc>
Checking for crash with only 7 instructions: <llc><crash>
Checking for crash with only 4 instructions: <llc>
Checking for crash with only 3 instructions: <llc>
Checking for crash with only 6 instructions: <llc>
Checking for crash with only 1 instruction: <llc>
Checking for crash with only 6 instructions: <llc>
Checking for crash with only 6 instructions: <llc>
Checking for crash with only 6 instructions: <llc>
Checking for crash with only 6 instructions: <llc><crash>
Checking for crash with only 5 instructions: <llc>
Checking for crash with only 5 instructions: <llc>
Checking for crash with only 5 instructions: <llc>
Checking for crash with only 5 instructions: <llc><crash>
Checking for crash with only 4 instructions: <llc>
Checking for crash with only 4 instructions: <llc><crash>
Checking for crash with only 3 instructions: <llc>
Checking for crash with only 3 instructions: <llc>
Checking for crash with only 3 instructions: <llc>
Checking for crash with only 3 instructions: <llc>

*** Attempting to reduce testcase by deleting instructions: Simplification Level #1
Checking instruction:   %5 = getelementptr inbounds %struct.ucontext_t.3.8.13, %struct.ucontext_t.3.8.13* %0, i64 0, i32 5, i32 1, i64 0, !dbg !98<llc>
Checking instruction:   call void @llvm.dbg.value(metadata i64* %5, metadata !80, metadata !DIExpression()), !dbg !99<llc>
Checking instruction:   %29 = add nsw i32 undef, 8, !dbg !100<llc>
Checking instruction:   call void @llvm.dbg.value(metadata i32 8, metadata !95, metadata !DIExpression()), !dbg !99<llc>

*** Attempting to reduce testcase by deleting instructions: Simplification Level #0
Checking instruction:   %5 = getelementptr inbounds %struct.ucontext_t.3.8.13, %struct.ucontext_t.3.8.13* %0, i64 0, i32 5, i32 1, i64 0, !dbg !98<llc>
Checking instruction:   call void @llvm.dbg.value(metadata i64* %5, metadata !80, metadata !DIExpression()), !dbg !99<llc>
Checking instruction:   %29 = add nsw i32 undef, 8, !dbg !100<llc>
Checking instruction:   call void @llvm.dbg.value(metadata i32 8, metadata !95, metadata !DIExpression()), !dbg !99<llc>
Checking for crash with metadata retained from 53 instructions: <llc>
Emitted bitcode to 'bugpoint-reduced-instructions.bc'

*** Attempting to strip the debug info: <llc>

*** Attempting to strip the debug type info: <llc>

*** Attempting to remove named metadata: Checking for crash with only these named metadata nodes: llvm.dbg.cu llvm.module.flags llvm.ident: <llc>
Checking for crash with only 12 named metadata operands: <llc>
Emitted bitcode to 'bugpoint-reduced-named-md.bc'

*** Attempting to perform final cleanups: <llc>
Emitted bitcode to 'bugpoint-reduced-simplified.bc'

bugpoint-reduced-simplified.bc.zip

llvmbot commented 1 year ago

@llvm/issue-subscribers-backend-aarch64

Author: None (rlcamp)

I first hit this when compiling some unrelated stack switching code, and then checked to see if it also affected libucontext, which it does. Steps to reproduce: fresh install of latest bookworm-based 64-bit raspberry pi OS lite apt install git clang git clone --depth 1 https://github.com/kaniini/libucontext.git cd libucontext make CC=clang results in: ```cp arch/common/include/libucontext/bits.h include/libucontext/bits.h clang -std=gnu99 -D_BSD_SOURCE -fPIC -DPIC -ggdb3 -O2 -Wall -Iinclude -Iarch/aarch64 -Iarch/common -DEXPORT_UNPREFIXED -c -o arch/aarch64/makecontext.o arch/aarch64/makecontext.c In file included from arch/aarch64/makecontext.c:15: In file included from /usr/include/string.h:26: In file included from /usr/include/aarch64-linux-gnu/bits/libc-header-start.h:33: /usr/include/features.h:194:3: warning: "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-W#warnings] warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" ^ arch/aarch64/makecontext.c:48:7: warning: incompatible pointer types assigning to 'unsigned long *' from 'unsigned long long *' [-Wincompatible-pointer-types] regp = &(ucp->uc_mcontext.regs[0]); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: clang -std=gnu99 -D_BSD_SOURCE -fPIC -DPIC -ggdb3 -O2 -Wall -Iinclude -Iarch/aarch64 -Iarch/common -DEXPORT_UNPREFIXED -c -o arch/aarch64/makecontext.o arch/aarch64/makecontext.c 1. <eof> parser at end of file 2. Code generation 3. Running pass 'Function Pass Manager' on module 'arch/aarch64/makecontext.c'. 4. Running pass 'AArch64 Assembly Printer' on function '@libucontext_makecontext' Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x44)[0x7fb34de4dc] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x70)[0x7fb34dc4b4] /lib/aarch64-linux-gnu/libLLVM-14.so.1(+0xdcb1c0)[0x7fb340b1c0] linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0x7fbbd507bc] /lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x132a9f0)[0x7fb396a9f0] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm11raw_ostream5writeEPKcm+0x164)[0x7fb34bb49c] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm9MCContext16createTempSymbolERKNS_5TwineEb+0xb4)[0x7fb4871048] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm9MCContext16createTempSymbolEv+0x3c)[0x7fb48713f0] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm16MCDwarfLineEntry4makeEPNS_10MCStreamerEPNS_9MCSectionE+0x3c)[0x7fb4879ec0] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm16MCObjectStreamer19emitInstructionImplERKNS_6MCInstERKNS_15MCSubtargetInfoE+0x94)[0x7fb4896934] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm16MCObjectStreamer15emitInstructionERKNS_6MCInstERKNS_15MCSubtargetInfoE+0x140)[0x7fb4896858] /lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x28adf50)[0x7fb4eedf50] /lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x2767f08)[0x7fb4da7f08] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm10AsmPrinter16emitFunctionBodyEv+0xa10)[0x7fb3c7ef30] /lib/aarch64-linux-gnu/libLLVM-14.so.1(+0x2764ba4)[0x7fb4da4ba4] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm19MachineFunctionPass13runOnFunctionERNS_8FunctionE+0x140)[0x7fb383122c] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x26c)[0x7fb3614390] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x3c)[0x7fb361af70] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x7b4)[0x7fb3614d98] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang17EmitBackendOutputERNS_17DiagnosticsEngineERKNS_19HeaderSearchOptionsERKNS_14CodeGenOptionsERKNS_13TargetOptionsERKNS_11LangOptionsEN4llvm9StringRefEPNSE_6ModuleENS_13BackendActionESt10unique_ptrINSE_17raw_pwrite_streamESt14default_deleteISK_EE+0xad0)[0x7fba11c680] /lib/aarch64-linux-gnu/libclang-cpp.so.14(+0x1b06f20)[0x7fba3d6f20] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang8ParseASTERNS_4SemaEbb+0x210)[0x7fb9316f1c] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang14FrontendAction7ExecuteEv+0x80)[0x7fbacd4444] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x328)[0x7fbac47d28] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x218)[0x7fbad47d20] clang(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0x810)[0x413608] clang[0x411df4] /lib/aarch64-linux-gnu/libclang-cpp.so.14(+0x207c5fc)[0x7fba94c5fc] /lib/aarch64-linux-gnu/libLLVM-14.so.1(_ZN4llvm20CrashRecoveryContext9RunSafelyENS_12function_refIFvvEEE+0xcc)[0x7fb340ae94] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver10CC1Command7ExecuteEN4llvm8ArrayRefINS2_8OptionalINS2_9StringRefEEEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb+0x120)[0x7fba94c000] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation14ExecuteCommandERKNS0_7CommandERPS3_+0x2b0)[0x7fba920f50] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZNK5clang6driver11Compilation11ExecuteJobsERKNS0_7JobListERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0x7c)[0x7fba92118c] /lib/aarch64-linux-gnu/libclang-cpp.so.14(_ZN5clang6driver6Driver18ExecuteCompilationERNS0_11CompilationERN4llvm15SmallVectorImplISt4pairIiPKNS0_7CommandEEEE+0xd8)[0x7fba9350c4] clang(main+0x23d4)[0x411648] /lib/aarch64-linux-gnu/libc.so.6(+0x27780)[0x7fb21b7780] /lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0x7fb21b7858] clang(_start+0x30)[0x40eef0] clang: error: clang frontend command failed with exit code 139 (use -v to see invocation) Debian clang version 14.0.6 Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang: note: diagnostic msg: /tmp/makecontext-3639f8.c clang: note: diagnostic msg: /tmp/makecontext-3639f8.sh clang: note: diagnostic msg: ******************** make: *** [Makefile:147: arch/aarch64/makecontext.o] Error 139 ``` [makecontext-3639f8.c.txt](https://github.com/llvm/llvm-project/files/13167907/makecontext-3639f8.c.txt) [makecontext-3639f8.sh.txt](https://github.com/llvm/llvm-project/files/13167912/makecontext-3639f8.sh.txt) I also followed the recommended steps in the LLVM bug report workflow which led to the following backend code generator result: ```clang -emit-llvm -std=gnu99 -D_BSD_SOURCE -fPIC -DPIC -ggdb3 -O2 -Wall -Iinclude -Iarch/aarch64 -Iarch/common -DEXPORT_UNPREFIXED -c -o arch/aarch64/makecontext.bc arch/aarch64/makecontext.c llc arch/aarch64/makecontext.bc # the above did not crash, so PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: llc arch/aarch64/makecontext.bc 1. Running pass 'Function Pass Manager' on module 'arch/aarch64/makecontext.bc'. 2. Running pass 'AArch64 Assembly Printer' on function '@libucontext_makecontext' #0 0x0000007fabb9e4dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9e4dc) #1 0x0000007fabb9c4b4 llvm::sys::RunSignalHandlers() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9c4b4) #2 0x0000007fabb9ea9c (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9ea9c) #3 0x0000007fb0fcb7bc (linux-vdso.so.1+0x7bc) #4 0x0000007fac02a9f0 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x132a9f0) #5 0x0000007fabb7b49c llvm::raw_ostream::write(char const*, unsigned long) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe7b49c) #6 0x0000007facf31048 llvm::MCContext::createTempSymbol(llvm::Twine const&, bool) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2231048) #7 0x0000007facf313f0 llvm::MCContext::createTempSymbol() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x22313f0) #8 0x0000007fac3576e8 llvm::DebugHandlerBase::endInstruction() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16576e8) #9 0x0000007fac3400d8 llvm::AsmPrinter::emitFunctionBody() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16400d8) #10 0x0000007fad464ba4 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2764ba4) #11 0x0000007fabef122c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x11f122c) #12 0x0000007fabcd4390 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4390) #13 0x0000007fabcdaf70 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfdaf70) #14 0x0000007fabcd4d98 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4d98) #15 0x000000000041043c main (/usr/lib/llvm-14/bin/llc+0x41043c) #16 0x0000007faa877780 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #17 0x0000007faa877858 call_init ./csu/../csu/libc-start.c:128:20 #18 0x0000007faa877858 __libc_start_main ./csu/../csu/libc-start.c:347:5 #19 0x000000000040ba70 _start (/usr/lib/llvm-14/bin/llc+0x40ba70) Segmentation fault bugpoint -run-llc arch/aarch64/makecontext.bc Read input file : 'arch/aarch64/makecontext.bc' *** All input ok Initializing execution environment: Found llc: /usr/lib/llvm-14/bin/llc Running the code generator to test for a crash: <llc> Generating reference output from raw program: <llc> Error running tool: /usr/lib/llvm-14/bin/llc -o bugpoint-test-program-be893e8.bc-654f6fd.llc.s bugpoint-test-program-be893e8.bc PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: /usr/lib/llvm-14/bin/llc -o bugpoint-test-program-be893e8.bc-654f6fd.llc.s bugpoint-test-program-be893e8.bc 1. Running pass 'Function Pass Manager' on module 'bugpoint-test-program-be893e8.bc'. 2. Running pass 'AArch64 Assembly Printer' on function '@libucontext_makecontext' #0 0x0000007f92dbe4dc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9e4dc) #1 0x0000007f92dbc4b4 llvm::sys::RunSignalHandlers() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9c4b4) #2 0x0000007f92dbea9c (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe9ea9c) #3 0x0000007f981e57bc (linux-vdso.so.1+0x7bc) #4 0x0000007f9324a9f0 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x132a9f0) #5 0x0000007f92d9b49c llvm::raw_ostream::write(char const*, unsigned long) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xe7b49c) #6 0x0000007f94151048 llvm::MCContext::createTempSymbol(llvm::Twine const&, bool) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2231048) #7 0x0000007f941513f0 llvm::MCContext::createTempSymbol() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x22313f0) #8 0x0000007f935776e8 llvm::DebugHandlerBase::endInstruction() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16576e8) #9 0x0000007f935600d8 llvm::AsmPrinter::emitFunctionBody() (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x16400d8) #10 0x0000007f94684ba4 (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x2764ba4) #11 0x0000007f9311122c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0x11f122c) #12 0x0000007f92ef4390 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4390) #13 0x0000007f92efaf70 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfdaf70) #14 0x0000007f92ef4d98 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib/aarch64-linux-gnu/libLLVM-14.so.1+0xfd4d98) #15 0x000000000041043c main (/usr/lib/llvm-14/bin/llc+0x41043c) #16 0x0000007f91a97780 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #17 0x0000007f91a97858 call_init ./csu/../csu/libc-start.c:128:20 #18 0x0000007f91a97858 __libc_start_main ./csu/../csu/libc-start.c:347:5 #19 0x000000000040ba70 _start (/usr/lib/llvm-14/bin/llc+0x40ba70) *** Debugging code generator crash! *** Attempting to reduce the number of function attributes in the testcase <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc> <llc> <llc> <llc><crash> <llc><crash> <llc><crash> <llc> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc> <llc> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc> <llc> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> <llc><crash> Checking for crash with changing conditionals to always jump to true: ... <49 total>: <llc><crash> Emitted bitcode to 'bugpoint-reduced-conditionals.bc' Checking for crash with only these blocks: ... <49 total>: <llc><crash> Emitted bitcode to 'bugpoint-reduced-blocks.bc' Checking for crash with CFG simplifying: ... <49 total>: <llc><crash> Emitted bitcode to 'bugpoint-reduced-simplifycfg.bc' Checking for crash with only 249 instructions: <llc><crash> Checking for crash with only 125 instructions: <llc><crash> Checking for crash with only 63 instructions: <llc> Checking for crash with only 62 instructions: <llc> Checking for crash with only 94 instructions: <llc> Checking for crash with only 31 instructions: <llc> Checking for crash with only 110 instructions: <llc> Checking for crash with only 15 instructions: <llc> Checking for crash with only 118 instructions: <llc> Checking for crash with only 7 instructions: <llc><crash> Checking for crash with only 4 instructions: <llc> Checking for crash with only 3 instructions: <llc> Checking for crash with only 6 instructions: <llc> Checking for crash with only 1 instruction: <llc> Checking for crash with only 6 instructions: <llc> Checking for crash with only 6 instructions: <llc> Checking for crash with only 6 instructions: <llc> Checking for crash with only 6 instructions: <llc><crash> Checking for crash with only 5 instructions: <llc> Checking for crash with only 5 instructions: <llc> Checking for crash with only 5 instructions: <llc> Checking for crash with only 5 instructions: <llc><crash> Checking for crash with only 4 instructions: <llc> Checking for crash with only 4 instructions: <llc><crash> Checking for crash with only 3 instructions: <llc> Checking for crash with only 3 instructions: <llc> Checking for crash with only 3 instructions: <llc> Checking for crash with only 3 instructions: <llc> *** Attempting to reduce testcase by deleting instructions: Simplification Level #1 Checking instruction: %5 = getelementptr inbounds %struct.ucontext_t.3.8.13, %struct.ucontext_t.3.8.13* %0, i64 0, i32 5, i32 1, i64 0, !dbg !98<llc> Checking instruction: call void @llvm.dbg.value(metadata i64* %5, metadata !80, metadata !DIExpression()), !dbg !99<llc> Checking instruction: %29 = add nsw i32 undef, 8, !dbg !100<llc> Checking instruction: call void @llvm.dbg.value(metadata i32 8, metadata !95, metadata !DIExpression()), !dbg !99<llc> *** Attempting to reduce testcase by deleting instructions: Simplification Level #0 Checking instruction: %5 = getelementptr inbounds %struct.ucontext_t.3.8.13, %struct.ucontext_t.3.8.13* %0, i64 0, i32 5, i32 1, i64 0, !dbg !98<llc> Checking instruction: call void @llvm.dbg.value(metadata i64* %5, metadata !80, metadata !DIExpression()), !dbg !99<llc> Checking instruction: %29 = add nsw i32 undef, 8, !dbg !100<llc> Checking instruction: call void @llvm.dbg.value(metadata i32 8, metadata !95, metadata !DIExpression()), !dbg !99<llc> Checking for crash with metadata retained from 53 instructions: <llc> Emitted bitcode to 'bugpoint-reduced-instructions.bc' *** Attempting to strip the debug info: <llc> *** Attempting to strip the debug type info: <llc> *** Attempting to remove named metadata: Checking for crash with only these named metadata nodes: llvm.dbg.cu llvm.module.flags llvm.ident: <llc> Checking for crash with only 12 named metadata operands: <llc> Emitted bitcode to 'bugpoint-reduced-named-md.bc' *** Attempting to perform final cleanups: <llc> Emitted bitcode to 'bugpoint-reduced-simplified.bc' ``` [bugpoint-reduced-simplified.bc.zip](https://github.com/llvm/llvm-project/files/13168007/bugpoint-reduced-simplified.bc.zip)
rlcamp commented 1 year ago

Update: I'm seeing this happen nondeterministically on any nontrivial C source file with clang on this particular OS image, on multiple instances of the same board, and not older OS images on the same hardware.

rlcamp commented 1 year ago

We are able to reproduce this on multiple Pi Zero 2W's, a Pi 3B, and NOT on a Pi 4 B, all with the same OS image. The same card was used with the Pi 3B and Pi 4B.