Skip to content

Compiler seg faults while building Linux kernel #42

Open
@connorkuehl

Description

@connorkuehl

Kees found this in testing.

I pulled latest changes from LLVM/Clang and applied the ASM goto series. Also applied Randstruct patches.

With Randstruct disabled the kernel builds fine.

With Randstruct enabled the compiler will segfault.

I find this part of the stack trace particularly interesting:

 #4 0x0000000003a4df10 clang::TagType::getDecl() const (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x3a4df10)
 #5 0x0000000001fdf305 (anonymous namespace)::ConstStructBuilder::Finalize(clang::QualType) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdf305)

But when I look at that method nothing is glaringly obviously wrong about it. I think there's got to be some corruption in the DeclContext as a result of our rearranging.

Stack dump:
0.	Program arguments: /home/kuehlcon/src/git/llvm-project/build/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name init_task.c -mrelocation-model static -mthread-model posix -fno-delete-null-pointer-checks -mllvm -warn-stack-size=2048 -relaxed-aliasing -fmath-errno -masm-verbose -no-integrated-as -mconstructor-aliases -fuse-init-array -mcode-model kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse -target-feature -mmx -target-feature -sse2 -target-feature -3dnow -target-feature -avx -target-feature -x87 -target-feature +retpoline-external-thunk -disable-red-zone -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /home/kuehlcon/src/git/linux/init/init_task.gcno -nostdsysteminc -nobuiltininc -resource-dir /home/kuehlcon/src/git/llvm-project/build/lib/clang/9.0.0 -dependency-file init/.init_task.o.d -MT init/init_task.o -sys-header-deps -isystem /home/kuehlcon/src/git/llvm-project/build/lib/clang/9.0.0/include -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -I ./arch/x86/include -I ./arch/x86/include/generated -I ./include -I ./arch/x86/include/uapi -I ./arch/x86/include/generated/uapi -I ./include/uapi -I ./include/generated/uapi -D __KERNEL__ -D CONFIG_AS_CFI=1 -D CONFIG_AS_CFI_SIGNAL_FRAME=1 -D CONFIG_AS_CFI_SECTIONS=1 -D CONFIG_AS_FXSAVEQ=1 -D CONFIG_AS_SSSE3=1 -D CONFIG_AS_AVX=1 -D CONFIG_AS_AVX2=1 -D CONFIG_AS_AVX512=1 -D CONFIG_AS_SHA1_NI=1 -D CONFIG_AS_SHA256_NI=1 -D KBUILD_BASENAME="init_task" -D KBUILD_MODNAME="init_task" -O2 -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -Werror-implicit-function-declaration -Werror=implicit-int -Wno-format-security -Wno-sign-compare -Wno-format-invalid-specifier -Wno-gnu -Wno-address-of-packed-member -Wno-tautological-compare -Wno-unused-const-variable -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides -Wno-unused-value -Wno-format -Wno-sign-compare -Wno-format-zero-length -Wno-uninitialized -std=gnu89 -fno-dwarf-directory-asm -fdebug-compilation-dir /home/kuehlcon/src/git/linux -ferror-limit 19 -fmessage-length 0 -fwrapv -stack-protector 2 -mstack-alignment=8 -fno-builtin-bcmp -fwchar-type=short -fno-signed-wchar -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o /tmp/init_task-bbbe6b.s -x c init/init_task.c 
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	init/init_task.c:17:29: Generating code for declaration 'init_signals'
/tmp/vdso32-setup-a99b3b.s: Assembler messages:
/tmp/vdso32-setup-a99b3b.s:146: Error: invalid operands (.data..read_mostly and *ABS* sections) for `&'
clang-9: error: assembler command failed with exit code 1 (use -v to see invocation)
make[3]: *** [arch/x86/entry/vdso/vdso32-setup.o] Error 1
make[3]: *** Waiting for unfinished jobs....
 #0 0x0000000001e2ee94 PrintStackTraceSignalHandler(void*) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1e2ee94)
 #1 0x0000000001e2cd1e llvm::sys::RunSignalHandlers() (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1e2cd1e)
 #2 0x0000000001e2f278 SignalHandler(int) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1e2f278)
 #3 0x00007f8c39297890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x0000000003a4df10 clang::TagType::getDecl() const (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x3a4df10)
 #5 0x0000000001fdf305 (anonymous namespace)::ConstStructBuilder::Finalize(clang::QualType) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdf305)
 #6 0x0000000001fdc9d4 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ConstExprEmitter, llvm::Constant*, clang::QualType>::Visit(clang::Stmt*, clang::QualType) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdc9d4)
 #7 0x0000000001fdaeda clang::CodeGen::ConstantEmitter::tryEmitPrivate(clang::Expr const*, clang::QualType) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdaeda)
 #8 0x0000000001fdbff8 clang::CodeGen::ConstantEmitter::tryEmitPrivateForMemory(clang::Expr const*, clang::QualType) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdbff8)
 #9 0x0000000001fe3440 (anonymous namespace)::ConstStructBuilder::Build(clang::InitListExpr*) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fe3440)
#10 0x0000000001fdc9c3 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ConstExprEmitter, llvm::Constant*, clang::QualType>::Visit(clang::Stmt*, clang::QualType) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdc9c3)
#11 0x0000000001fdadc5 clang::CodeGen::ConstantEmitter::tryEmitPrivateForVarInit(clang::VarDecl const&) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdadc5)
#12 0x0000000001fdbf10 clang::CodeGen::ConstantEmitter::tryEmitForInitializer(clang::VarDecl const&) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x1fdbf10)
#13 0x000000000204b84f clang::CodeGen::CodeGenModule::EmitGlobalVarDefinition(clang::VarDecl const*, bool) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x204b84f)
#14 0x000000000204533b clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x204533b)
#15 0x000000000203d38f clang::CodeGen::CodeGenModule::EmitDeferred() (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x203d38f)
#16 0x000000000203c687 clang::CodeGen::CodeGenModule::Release() (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x203c687)
#17 0x00000000028988b4 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x28988b4)
#18 0x0000000002896157 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x2896157)
#19 0x00000000030278e3 clang::ParseAST(clang::Sema&, bool, bool) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x30278e3)
#20 0x000000000241ade7 clang::FrontendAction::Execute() (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x241ade7)
#21 0x00000000023c20a8 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x23c20a8)
#22 0x00000000024ae245 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x24ae245)
#23 0x0000000000920c94 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x920c94)
#24 0x000000000091ef68 main (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x91ef68)
#25 0x00007f8c37f40b97 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#26 0x000000000091c42a _start (/home/kuehlcon/src/git/llvm-project/build/bin/clang-9+0x91c42a)
clang-9: error: unable to execute command: Segmentation fault (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 9.0.0 (git@github.com:clang-randstruct/llvm-project.git deb4b7d7f012ad7bf83c988c1979eb746ac5dc6d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/kuehlcon/src/git/llvm-project/build/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-9: note: diagnostic msg: 
********************

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions