Skip to content
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

clang: assertion `(Fn->containsErrors() || llvm::any_of(ArgExprs, [](clang::Expr *E) { return E->containsErrors(); })) && "should only occur in error-recovery path." #48636

Closed
llvmbot opened this issue Feb 20, 2021 · 4 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla c clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-invalid

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 20, 2021

Bugzilla Link 49292
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @chengniansun,@zygoloid

Extended Description

An ill-formed program causes an assertion failure. I think it is less-interesting, so I leave it here for any future improvement.

$ cat /tmp/test-f3c9e6.c

1 ""

1 "test.c"

int c(int *x) {
return x[0];
}

int main() {
int b[] = {""()};
return c(b)
}

$ cat /tmp/test-f3c9e6.sh

Crash reproducer for clang version 13.0.0 (https://github.com/llvm/llvm-project.git b006902)

Driver args: "-c" "-x" "c" "-o" "/tmp/c.out" "test.c"

Original command: "/data/xxx/git/llvm-project/build_trunk/bin/clang-13" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "test.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" "/data/xxx/git/llvm-project/build_trunk/lib/clang/13.0.0" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/data/xxx/git/llvm-project/build_trunk/lib/clang/13.0.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir=/home/xxx/data/docker_share/clang" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-o" "/tmp/c.out" "-x" "c" "test.c"

"/data/xxx/git/llvm-project/build_trunk/bin/clang-13" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "test.c" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/home/xxx/data/docker_share/clang" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig" "-x" "c" "test-f3c9e6.c"

$ /data/xxx/git/llvm-project/build_trunk/bin/clang -c -x c -o /tmp/c.out test.c

test.c:6:16: error: called object type 'char [1]' is not a function or function pointer
int b[] = {""()};
~~^
clang: /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaExpr.cpp:6485: clang::ExprResult clang::Sema::BuildCallExpr(clang::Scope *, clang::Expr *, clang::SourceLocation, clang::MultiExprArg, clang::SourceLocation, clang::Expr *, bool, bool): Assertion `(Fn->containsErrors() || llvm::any_of(ArgExprs, [](clang::Expr *E) { return E->containsErrors(); })) && "should only occur in error-recovery path."' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /data/xxx/git/llvm-project/build_trunk/bin/clang -c -x c -o /tmp/c.out test.c

  1.  test.c:7:13: current parser token ')'
    
  2.  test.c:5:12: parsing function body 'main'
    
  3.  test.c:5:12: in compound statement ('{}')
    

#​0 0x0000000000dfd0a1 __interceptor_backtrace.part.117 asan_interceptors.cc.o:0:0
#​1 0x000000000d7fb43a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:561:7
#​2 0x000000000d7f1bc1 llvm::sys::RunSignalHandlers() /home/xxx/data/git/llvm-project/llvm/lib/Support/Signals.cpp:72:18
#​3 0x000000000d7f805f llvm::sys::CleanupOnSignal(unsigned long) /home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
#​4 0x000000000d504245 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:75:5
#​5 0x000000000d504d0c CrashRecoverySignalHandler(int) /home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:389:1
#​6 0x00007f5c701d28a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#​7 0x00007f5c6fbf5f47 raise /build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#​8 0x00007f5c6fbf78b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
#​9 0x00007f5c6fbe742a __assert_fail_base /build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
#​10 0x00007f5c6fbe74a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
#​11 0x00000000198b9e8d clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*, bool, bool) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaExpr.cpp:6460:13
#​12 0x000000001994232c clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaExpr.cpp:6317:7
#​13 0x0000000018483c37 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:2064:23
#​14 0x000000001848d936 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:1809:7
#​15 0x0000000018477884 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:681:20
#​16 0x0000000018477884 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:173:0
#​17 0x0000000018477406 clang::Parser::ParseExpression(clang::Parser::TypeCastState) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:125:10
#​18 0x000000001865cac6 clang::Parser::ParseReturnStatement() /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:2206:11
#​19 0x0000000018644e46 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:292:11
#​20 0x0000000018643e2a clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:115:3
#​21 0x0000000018663e85 clang::Parser::ParseCompoundStatementBody(bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:1110:11
#​22 0x0000000018669c9f clang::ActionResult<clang::Stmt*, true>::isInvalid() const /home/xxx/data/git/llvm-project/clang/include/clang/Sema/Ownership.h:0:0
#​23 0x0000000018669c9f clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:2274:0
#​24 0x000000001832973d clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:0:10
#​25 0x00000000183a8a06 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:1994:27
#​26 0x0000000018325412 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:1134:10
#​27 0x0000000018322237 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:1150:12
#​28 0x000000001831f00d clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:0:12
#​29 0x0000000018317f4e clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:716:10
#​30 0x00000000183047f9 clang::ParseAST(clang::Sema&, bool, bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseAST.cpp:157:15
#​31 0x00000000105c90c3 clang::ASTFrontendAction::ExecuteAction() /home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:1
#​32 0x0000000012cff7d9 clang::CodeGenAction::ExecuteAction() /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1082:30
#​33 0x00000000105c5efd clang::FrontendAction::Execute() /home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:0:8
#​34 0x0000000010394e0a llvm::Error::operator bool() /home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Error.h:0:0
#​35 0x0000000010394e0a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/xxx/data/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:949:0
#​36 0x0000000010ac5a2e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/xxx/data/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:25
#​37 0x0000000000e9b85d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/xxx/data/git/llvm-project/clang/tools/driver/cc1_main.cpp:246:15
#​38 0x0000000000e82e17 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:330:12
#​39 0x000000000ff0a39d clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::$_1::operator()() const /home/xxx/data/git/llvm-project/clang/lib/Driver/Job.cpp:404:30
#​40 0x000000000ff0a39d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::$_1>(long) /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:185:0
#​41 0x000000000d503de4 llvm::function_ref<void ()>::operator()() const /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:209:12
#​42 0x000000000d503de4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:424:0
#​43 0x000000000ff08be2 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optionalllvm::StringRef >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const /home/xxx/data/git/llvm-project/clang/lib/Driver/Job.cpp:404:7
#​44 0x000000000fdfc32e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const /home/xxx/data/git/llvm-project/clang/lib/Driver/Compilation.cpp:195:15
#​45 0x000000000fdfcf7c clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const /home/xxx/data/git/llvm-project/clang/lib/Driver/Compilation.cpp:248:19
#​46 0x000000000fe6126a llvm::SmallVectorBase::empty() const /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/SmallVector.h:0:0
#​47 0x000000000fe6126a clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) /home/xxx/data/git/llvm-project/clang/lib/Driver/Driver.cpp:1529:0
#​48 0x0000000000e7fd4f main /home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:502:21
#​49 0x00007f5c6fbd8b97 __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#​50 0x0000000000d7aada _start (/data/xxx/git/llvm-project/build_trunk/bin/clang+0xd7aada)
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 13.0.0 (https://github.com/llvm/llvm-project.git b006902)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/xxx/git/llvm-project/build_trunk/bin
clang-13: note: diagnostic msg:


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


@chengniansun
Copy link

A duplicate.

$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 699d474)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/cnsun/usr/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64

$ cat mutant.c
struct bar {
char;
} bar[] = {"I"()};
main_test() {
struct bar b1[sizeof bar];
memmove(b1, bar, bar);
}

$ clang-trunk -w mutant.c
mutant.c:3:15: error: called object type 'char [2]' is not a function or function pointer
} bar[] = {"I"()};
~~~^
clang-13: /tmp/tmp.MZZAoX1zOr-clang-builder/llvm-project/clang/lib/Sema/SemaExpr.cpp:6547: clang::ExprResult clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, clang::MultiExprArg, clang::SourceLocation, clang::Expr*, bool, bool): Assertion `(Fn->containsErrors() || llvm::any_of(ArgExprs, [](clang::Expr *E) { return E->containsErrors(); })) && "should only occur in error-recovery path."' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /scratch/software/clang-trunk/bin/clang-13 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name mutant.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210627_114817_1332/delta/perses_result_1 -resource-dir /scratch/software/clang-trunk/lib/clang/13.0.0 -c-isystem . -c-isystem /usr/local/include/cmsith -internal-isystem /scratch/software/clang-trunk/lib/clang/13.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -w -fdebug-compilation-dir=/scratch/cnsun/workspace/perses-fuzzer/default_c_finding_folder/crash_20210627_114817_1332/delta/perses_result_1 -ferror-limit 19 -fgnuc-version=4.2.1 -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-0f75cc.o -x c mutant.c

  1. mutant.c:6:23: current parser token ')'
  2. mutant.c:4:13: parsing function body 'main_test'
  3. mutant.c:4:13: in compound statement ('{}')
    #​0 0x00005605d0654684 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
    #​1 0x00005605d0651e3e SignalHandler(int) Signals.cpp:0:0
    #​2 0x00007fcbbe8ee3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
    #​3 0x00007fcbbe38d18b raise /build/glibc-ZN95T4/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
    #​4 0x00007fcbbe36c859 abort /build/glibc-ZN95T4/glibc-2.31/stdlib/abort.c:81:7
    #​5 0x00007fcbbe36c729 get_sysdep_segment_value /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:509:8
    #​6 0x00007fcbbe36c729 _nl_load_domain /build/glibc-ZN95T4/glibc-2.31/intl/loadmsgcat.c:970:34
    #​7 0x00007fcbbe37df36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)
    #​8 0x00005605d2d17c58 clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x6020c58)
    #​9 0x00005605d2d18bcd clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRefclang::Expr*, clang::SourceLocation, clang::Expr*) (/scratch/software/clang-trunk/bin/clang-13+0x6021bcd)
    #​10 0x00005605d28cc1bb clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/scratch/software/clang-trunk/bin/clang-13+0x5bd51bb)
    #​11 0x00005605d28c52c2 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/scratch/software/clang-trunk/bin/clang-13+0x5bce2c2)
    #​12 0x00005605d28c7dbb clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/scratch/software/clang-trunk/bin/clang-13+0x5bd0dbb)
    #​13 0x00005605d28c7e5d clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/scratch/software/clang-trunk/bin/clang-13+0x5bd0e5d)
    #​14 0x00005605d28cb3bd clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/scratch/software/clang-trunk/bin/clang-13+0x5bd43bd)
    #​15 0x00005605d2932ffe clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/scratch/software/clang-trunk/bin/clang-13+0x5c3bffe)
    #​16 0x00005605d292a592 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributesWithRange&) (/scratch/software/clang-trunk/bin/clang-13+0x5c33592)
    #​17 0x00005605d292af7a clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/scratch/software/clang-trunk/bin/clang-13+0x5c33f7a)
    #​18 0x00005605d292bef9 clang::Parser::ParseCompoundStatementBody(bool) (/scratch/software/clang-trunk/bin/clang-13+0x5c34ef9)
    #​19 0x00005605d292e50a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/scratch/software/clang-trunk/bin/clang-13+0x5c3750a)
    #​20 0x00005605d28747a2 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/scratch/software/clang-trunk/bin/clang-13+0x5b7d7a2)
    #​21 0x00005605d28a1100 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/scratch/software/clang-trunk/bin/clang-13+0x5baa100)
    #​22 0x00005605d286efa6 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/scratch/software/clang-trunk/bin/clang-13+0x5b77fa6)
    #​23 0x00005605d286f591 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
    #​24 0x00005605d2875d97 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/scratch/software/clang-trunk/bin/clang-13+0x5b7ed97)
    #​25 0x00005605d287732e clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5b8032e)
    #​26 0x00005605d2869b79 clang::ParseAST(clang::Sema&, bool, bool) (/scratch/software/clang-trunk/bin/clang-13+0x5b72b79)
    #​27 0x00005605d17b1218 clang::CodeGenAction::ExecuteAction() (/scratch/software/clang-trunk/bin/clang-13+0x4aba218)
    #​28 0x00005605d1060a79 clang::FrontendAction::Execute() (/scratch/software/clang-trunk/bin/clang-13+0x4369a79)
    #​29 0x00005605d0ff3cc6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/software/clang-trunk/bin/clang-13+0x42fccc6)
    #​30 0x00005605d113e9c0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/software/clang-trunk/bin/clang-13+0x44479c0)
    #​31 0x00005605cdf5c696 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/software/clang-trunk/bin/clang-13+0x1265696)
    #​32 0x00005605cdf589d8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
    #​33 0x00005605cde860e6 main (/scratch/software/clang-trunk/bin/clang-13+0x118f0e6)
    #​34 0x00007fcbbe36e0b3 __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:342:3
    #​35 0x00005605cdf5854e _start (/scratch/software/clang-trunk/bin/clang-13+0x126154e)
    clang-13: error: unable to execute command: Aborted (core dumped)
    clang-13: error: clang frontend command failed due to signal (use -v to see invocation)
    clang version 13.0.0 (https://github.com/llvm/llvm-project.git 699d474)
    Target: x86_64-unknown-linux-gnu
    Thread model: posix
    InstalledDir: /home/cnsun/usr/bin
    clang-13: note: diagnostic msg:

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


@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@AaronBallman AaronBallman added c clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid confirmed Verified by a second party and removed clang Clang issues not falling into any other category labels Jun 21, 2023
@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 21, 2023

@llvm/issue-subscribers-clang-frontend

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 21, 2023

@llvm/issue-subscribers-c

@AaronBallman
Copy link
Collaborator

The issue reproduces as of Clang 16.0.0: https://gcc.godbolt.org/z/3Khfaa747

Note, the issue only reproduces in C, not in C++, and requires an asserts build to see.

@hokein hokein self-assigned this Jul 8, 2023
@hokein hokein closed this as completed in 9ca395b Jul 11, 2023
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Jul 19, 2023
  [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

  Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
  code), we propagate the contains-errors bit for C-code path.

  Fixes llvm/llvm-project#50236
  Fixes llvm/llvm-project#50243
  Fixes llvm/llvm-project#48636
  Fixes llvm/llvm-project#50320

  Differential Revision: https://reviews.llvm.org/D154861

This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors()
|| RHSExpr->containsErrors()) && "Should only occur in error-recovery
path."), function BuildBinOp') when building parts of dtrace in certain
scenarios.

Reported by:	dstolfa
PR:		271047
MFC after:	1 month
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Jul 23, 2023
  [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

  Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
  code), we propagate the contains-errors bit for C-code path.

  Fixes llvm/llvm-project#50236
  Fixes llvm/llvm-project#50243
  Fixes llvm/llvm-project#48636
  Fixes llvm/llvm-project#50320

  Differential Revision: https://reviews.llvm.org/D154861

This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors()
|| RHSExpr->containsErrors()) && "Should only occur in error-recovery
path."), function BuildBinOp') when building parts of dtrace in certain
scenarios.

Reported by:	dstolfa
PR:		271047
MFC after:	1 month

(cherry picked from commit 8d0cab8)
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this issue Sep 6, 2023
  [clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.

  Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
  code), we propagate the contains-errors bit for C-code path.

  Fixes llvm/llvm-project#50236
  Fixes llvm/llvm-project#50243
  Fixes llvm/llvm-project#48636
  Fixes llvm/llvm-project#50320

  Differential Revision: https://reviews.llvm.org/D154861

This fixes an assertion ('Assertion failed: ((LHSExpr->containsErrors()
|| RHSExpr->containsErrors()) && "Should only occur in error-recovery
path."), function BuildBinOp') when building parts of dtrace in certain
scenarios.

Reported by:	dstolfa
PR:		271047
MFC after:	1 month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party crash-on-invalid
Projects
None yet
Development

No branches or pull requests

4 participants