[llvm-bugs] [Bug 49258] New: clang: segment fault in llvm::cast_retty<clang::Expr, clang::Stmt const*>::ret_type

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 18 19:08:18 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49258

            Bug ID: 49258
           Summary: clang: segment fault in llvm::cast_retty<clang::Expr,
                    clang::Stmt const*>::ret_type
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhan3299 at purdue.edu
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

only version 11.0 crashes on this invalid input (not 12.0 and trunk).


$ cat  /tmp/test-179b70.c
# 1 "<built-in>"
# 1 "test.c"
int a[sizeof((int) staticIr)];


$ cat /tmp/test-179b70.sh
# Crash reproducer for clang version 11.1.0
(https://github.com/llvm/llvm-project.git
1fdec59bffc11ae37eb51a1b9869f0696bfd5312)
# Driver args: "-o" "/tmp/a.out" "-x" "c" "-c" "test.c"
# Original command:  "/data/xxx/git/llvm-project/build/bin/clang-11" "-cc1"
"-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-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" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
"-resource-dir" "/data/xxx/git/llvm-project/build/lib/clang/11.1.0"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/data/xxx/git/llvm-project/build/lib/clang/11.1.0/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-fdebug-compilation-dir" "/data/xxx/docker_share/clang"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig"
"-o" "/tmp/a.out" "-x" "c" "test.c"
 "/data/xxx/git/llvm-project/build/bin/clang-11" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-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" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcolor-diagnostics" "-faddrsig"
"-x" "c" "test-179b70.c"


$ ./clang -o /tmp/a.out -x c -c test.c
test.c:1:20: error: use of undeclared identifier 'staticIr'; did you mean
'static'?
int a[sizeof((int) staticIr)];
                   ^~~~~~~~
                   static
test.c:1:20: error: address of overloaded function 'staticIr' does not match
required type 'int'
int a[sizeof((int) staticIr)];
                   ^~~~~~~~
shouldn't see dependent / unresolved nodes here
UNREACHABLE executed at
/home/xxx/data/git/llvm-project/clang/lib/AST/Expr.cpp:3422!
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/bin/clang -o
/tmp/a.out -x c -c test.c
1.      test.c:1:29: current parser token ']'
 #0 0x0000000006e97306 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:560:7
 #1 0x0000000006e9266e llvm::sys::RunSignalHandlers()
/home/xxx/data/git/llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x0000000006e95560 llvm::sys::CleanupOnSignal(unsigned long)
/home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:361:3
 #3 0x0000000006c878a5 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
/home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:77:5
 #4 0x0000000006c87d20 CrashRecoverySignalHandler(int)
/home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:383:1
 #5 0x00007f3ed489e8a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #6 0x00007f3ed3564f47 gsignal
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #7 0x00007f3ed35668b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #8 0x0000000006c97244
/home/xxx/data/git/llvm-project/llvm/lib/Support/ErrorHandling.cpp:210:3
 #9 0x000000000f520ba8 llvm::cast_retty<clang::Expr, clang::Stmt
const*>::ret_type llvm::cast<clang::Expr, clang::Stmt const>(clang::Stmt
const*)
/home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Casting.h:269:3
#10 0x000000000f520ba8 clang::Expr::HasSideEffects(clang::ASTContext const&,
bool) const /home/xxx/data/git/llvm-project/clang/lib/AST/Expr.cpp:3673:0
#11 0x000000000f520a0f clang::Expr::HasSideEffects(clang::ASTContext const&,
bool) const /home/xxx/data/git/llvm-project/clang/lib/AST/Expr.cpp:3673:30
#12 0x000000000f520a0f clang::Expr::HasSideEffects(clang::ASTContext const&,
bool) const /home/xxx/data/git/llvm-project/clang/lib/AST/Expr.cpp:3673:30
#13 0x000000000d413c90
clang::Sema::CheckUnaryExprOrTypeTraitOperand(clang::Expr*,
clang::UnaryExprOrTypeTrait)
/home/xxx/data/git/llvm-project/clang/lib/Sema/SemaExpr.cpp:4102:7
#14 0x000000000d4186e5
clang::Sema::CreateUnaryExprOrTypeTraitExpr(clang::Expr*,
clang::SourceLocation, clang::UnaryExprOrTypeTrait)
/home/xxx/data/git/llvm-project/clang/lib/Sema/SemaExpr.cpp:4443:17
#15 0x000000000d4194a9
clang::Sema::ActOnUnaryExprOrTypeTraitExpr(clang::SourceLocation,
clang::UnaryExprOrTypeTrait, bool, void*, clang::SourceRange)
/home/xxx/data/git/llvm-project/clang/lib/Sema/SemaExpr.cpp:0:23
#16 0x000000000c920e1b clang::Parser::ParseUnaryExprOrTypeTraitExpression()
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:2476:23
#17 0x000000000c90f5b5
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:0:11
#18 0x000000000c902c60
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
#19 0x000000000c8fe5ef
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:176:10
#20 0x000000000c8a72f4
_ZN4llvm12function_refIFN5clang12ActionResultIPNS1_4ExprELb1EEES4_EEC2IZNS1_4Sema25CorrectDelayedTyposInExprES5_PNS1_7VarDeclEbS7_Ed_UlS4_E_EEOT_PNSt9enable_ifIXntsr3std7is_sameINSt9remove_cvINSt16remove_referenceISD_E4typeEE4typeES7_EE5valueEvE4typeE
/home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:0:0
#21 0x000000000c8a72f4
clang::Parser::ParseBracketDeclarator(clang::Declarator&)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:6947:0
#22 0x000000000c89ef17 clang::Parser::ParseDirectDeclarator(clang::Declarator&)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:6047:3
#23 0x000000000c899af1
clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void
(clang::Parser::*)(clang::Declarator&))
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:5628:5
#24 0x000000000c87fc39 clang::Declarator::hasName() const
/home/xxx/data/git/llvm-project/clang/include/clang/Sema/DeclSpec.h:0:0
#25 0x000000000c87fc39 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:1864:0
#26 0x000000000c83020d
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:0:10
#27 0x000000000c82e939
clang::Parser::ObjCDeclContextSwitch::~ObjCDeclContextSwitch()
/home/xxx/data/git/llvm-project/clang/include/clang/Parse/Parser.h:0:0
#28 0x000000000c82e939
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:1116:0
#29 0x000000000c82c6a1
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:935:12
#30 0x000000000c827ecc
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
/home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:683:10
#31 0x000000000c826ccc
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
/home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:555:26
#32 0x000000000c81cf4a clang::ParseAST(clang::Sema&, bool, bool)
/home/xxx/data/git/llvm-project/clang/lib/Parse/ParseAST.cpp:157:15
#33 0x000000000861c2a2 clang::ASTFrontendAction::ExecuteAction()
/home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1059:1
#34 0x00000000099decd8 clang::CodeGenAction::ExecuteAction()
/home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1184:28
#35 0x000000000861a51a clang::FrontendAction::Execute()
/home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:10
#36 0x000000000854eaa7 llvm::Error::operator bool()
/home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Error.h:0:0
#37 0x000000000854eaa7
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/xxx/data/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:0
#38 0x00000000088f183f clang::CompilerInstance::getFrontendOpts()
/home/xxx/data/git/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:0:0
#39 0x00000000088f183f
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/xxx/data/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:279:0
#40 0x0000000000b094cc llvm::TimeTraceScope::~TimeTraceScope()
/home/xxx/data/git/llvm-project/llvm/include/llvm/Support/TimeProfiler.h:0:0
#41 0x0000000000b094cc cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/xxx/data/git/llvm-project/clang/tools/driver/cc1_main.cpp:241:0
#42 0x0000000000afaf3b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:330:12
#43 0x00000000082c1350
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::$_1::operator()() const
/home/xxx/data/git/llvm-project/clang/lib/Driver/Job.cpp:400:30
#44 0x00000000082c1350 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::$_1>(long)
/home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:185:0
#45 0x0000000006c8767d
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
/home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:420:1
#46 0x00000000082bfbe7
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
/home/xxx/data/git/llvm-project/clang/lib/Driver/Job.cpp:400:12
#47 0x000000000822acca std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::empty() const
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/basic_string.h:0:0
#48 0x000000000822acca
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
/home/xxx/data/git/llvm-project/clang/lib/Driver/Compilation.cpp:196:0
#49 0x000000000822b754
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:246:19
#50 0x0000000008266f77 llvm::SmallVectorBase<unsigned int>::empty() const
/home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/SmallVector.h:0:0
#51 0x0000000008266f77
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:1509:0
#52 0x0000000000af95ae main
/home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:502:21
#53 0x00007f3ed3547b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#54 0x0000000000af38ea _start
(/data/xxx/git/llvm-project/build/bin/clang+0xaf38ea)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.1.0 (https://github.com/llvm/llvm-project.git
1fdec59bffc11ae37eb51a1b9869f0696bfd5312)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/xxx/git/llvm-project/build/bin
clang-11: note: diagnostic msg:
********************

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

********************

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210219/51c4192a/attachment-0001.html>


More information about the llvm-bugs mailing list