Issue |
129873
|
Summary |
Clang segfault in clang::Sema::PushCompoundScope
|
Labels |
clang
|
Assignees |
|
Reporter |
melver
|
Clang crashes in clang::Sema::PushCompoundScope:
```
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: /opt/llvm/bin/clang -Wp,-MMD,kernel/sched/.core.o.d -nostdinc -I../arch/x86/include -I./arch/x86/include/generated -I../include -I./include -I../arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/compiler-version.h -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -fmacro-prefix-map=../= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -m64 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup -march=core2 -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mretpoline-external-thunk -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fpatchable-function-entry=11,11 -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-stack-clash-protection -pg -mfentry -DCC_USING_NOP_MCOUNT -DCC_USING_FENTRY -fsanitize=kcfi -falign-functions=16 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-gnu -Wno-format-overflow-non-kprintf -Wno-format-truncation-non-kprintf -Wvla -Wno-pointer-sign -Wcast-function-type -Wimplicit-fallthrough -Werror=date-time -Werror=incompatible-pointer-types -Wenum-conversion -Wextra -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-format-overflow -Wno-override-init -Wno-pointer-to-enum-cast -Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access -Wno-enum-compare-conditional -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-enum-enum-conversion -Wno-sign-compare -Wno-unused-parameter -g -Wno-unused-but-set-variable -DWARN_CAPABILITY_ANALYSIS -fexperimental-late-parse-attributes -Wthread-safety -I../kernel/sched -Ikernel/sched -DKBUILD_MODFILE=\"kernel/sched/core\" -DKBUILD_BASENAME=\"core\" -DKBUILD_MODNAME=\"core\" -D__KBUILD_MODNAME=kmod_core -c -o kernel/sched/core.o ../kernel/sched/core.c
1. ../kernel/sched/sched.h:1816:2 <Spelling=../include/linux/percpu-defs.h:217:37>: current parser token '\
do'
2. ../kernel/sched/sched.h:1816:2 <Spelling=../include/linux/percpu-defs.h:236:2>: in compound statement ('{}')
#0 0x000055e362aee5e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm/bin/clang+0x43435e8)
#1 0x000055e362aec2ee llvm::sys::RunSignalHandlers() (/opt/llvm/bin/clang+0x43412ee)
#2 0x000055e362a7ca49 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f6e08049d20 (/lib/x86_64-linux-gnu/libc.so.6+0x3fd20)
#4 0x000055e36467d629 clang::Sema::PushCompoundScope(bool) (/opt/llvm/bin/clang+0x5ed2629)
#5 0x000055e3645f9fee clang::Parser::ParseCompoundStatementBody(bool) (/opt/llvm/bin/clang+0x5e4efee)
#6 0x000055e3645f5a0d clang::Parser::ParseCompoundStatement(bool) (/opt/llvm/bin/clang+0x5e4aa0d)
#7 0x000055e36458a673 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/opt/llvm/bin/clang+0x5ddf673)
#8 0x000055e364587c6e clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/llvm/bin/clang+0x5ddcc6e)
#9 0x000055e364586c6c clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/llvm/bin/clang+0x5ddbc6c)
#10 0x000055e364583278 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/llvm/bin/clang+0x5dd8278)
#11 0x000055e36458ad15 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/opt/llvm/bin/clang+0x5ddfd15)
#12 0x000055e364587c6e clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/llvm/bin/clang+0x5ddcc6e)
#13 0x000055e364584581 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/llvm/bin/clang+0x5dd9581)
#14 0x000055e364587b9f clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/llvm/bin/clang+0x5ddcb9f)
#15 0x000055e364583278 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/llvm/bin/clang+0x5dd8278)
#16 0x000055e36458ad15 clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/opt/llvm/bin/clang+0x5ddfd15)
#17 0x000055e364587c6e clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/llvm/bin/clang+0x5ddcc6e)
#18 0x000055e364583278 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/llvm/bin/clang+0x5dd8278)
#19 0x000055e3645b8197 clang::Parser::ParseAttributeArgumentList(clang::IdentifierInfo const&, llvm::SmallVectorImpl<clang::Expr*>&, clang::ParsedAttributeArgumentsProperties) (/opt/llvm/bin/clang+0x5e0d197)
#20 0x000055e3645ba694 clang::Parser::ParseAttributeArgsCommon(clang::IdentifierInfo*, clang::SourceLocation, clang::ParsedAttributes&, clang::SourceLocation*, clang::IdentifierInfo*, clang::SourceLocation, clang::AttributeCommonInfo::Form) (/opt/llvm/bin/clang+0x5e0f694)
#21 0x000055e3645b776b clang::Parser::ParseGNUAttributeArgs(clang::IdentifierInfo*, clang::SourceLocation, clang::ParsedAttributes&, clang::SourceLocation*, clang::IdentifierInfo*, clang::SourceLocation, clang::AttributeCommonInfo::Form, clang::Declarator*) (/opt/llvm/bin/clang+0x5e0c76b)
#22 0x000055e3646189ff clang::Parser::ParseLexedAttribute(clang::Parser::LateParsedAttribute&, bool, bool) (/opt/llvm/bin/clang+0x5e6d9ff)
#23 0x000055e364618eef clang::Parser::ParseLexedAttributeList(clang::Parser::LateParsedAttrList&, clang::Decl*, bool, bool) (/opt/llvm/bin/clang+0x5e6deef)
#24 0x000055e3645c1fc7 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/llvm/bin/clang+0x5e16fc7)
#25 0x000055e36456ebad clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/llvm/bin/clang+0x5dc3bad)
#26 0x000055e36456e599 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/llvm/bin/clang+0x5dc3599)
#27 0x000055e36456d938 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/llvm/bin/clang+0x5dc2938)
#28 0x000055e36456c233 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/llvm/bin/clang+0x5dc1233)
#29 0x000055e3645689fe clang::ParseAST(clang::Sema&, bool, bool) (/opt/llvm/bin/clang+0x5dbd9fe)
#30 0x000055e3635cba6d clang::FrontendAction::Execute() (/opt/llvm/bin/clang+0x4e20a6d)
#31 0x000055e363548484 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/llvm/bin/clang+0x4d9d484)
#32 0x000055e363680212 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/llvm/bin/clang+0x4ed5212)
#33 0x000055e3611430b2 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/llvm/bin/clang+0x29980b2)
#34 0x000055e36113fdc1 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x000055e3633d7399 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#36 0x000055e362a7c868 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/llvm/bin/clang+0x42d1868)
#37 0x000055e3633d6de5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/llvm/bin/clang+0x4c2bde5)
#38 0x000055e36339df7f clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/llvm/bin/clang+0x4bf2f7f)
#39 0x000055e36339e11e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/llvm/bin/clang+0x4bf311e)
#40 0x000055e3633b736d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/llvm/bin/clang+0x4c0c36d)
#41 0x000055e36113f73a clang_main(int, char**, llvm::ToolContext const&) (/opt/llvm/bin/clang+0x299473a)
#42 0x000055e36114cfa7 main (/opt/llvm/bin/clang+0x29a1fa7)
#43 0x00007f6e08033d68 (/lib/x86_64-linux-gnu/libc.so.6+0x29d68)
#44 0x00007f6e08033e25 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e25)
#45 0x000055e36113dae1 _start (/opt/llvm/bin/clang+0x2992ae1)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
ClangBuiltLinux clang version 21.0.0git (https://github.com/llvm/llvm-project d0f472c246911e35656bf24fd282f80d7482211a)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm/bin
```
To reproduce:
[core-d0a8fd.c.txt](https://github.com/user-attachments/files/19088234/core-d0a8fd.c.txt)
[core-d0a8fd.sh.txt](https://github.com/user-attachments/files/19088235/core-d0a8fd.sh.txt)
Report courtesy of Peter Zijlstra.
I was able to confirm the crash on my own Clang instance as well:
```
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 829e2a55261890e15102d978f714001a2d1acf85)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/google/home/elver/third_party/llvm/build/bin
Build config: +assertions
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs