[llvm-bugs] [Bug 49182] New: clang++ 11.0 segment fault

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 14 15:14:40 PST 2021


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

            Bug ID: 49182
           Summary: clang++ 11.0 segment fault
           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

Following segment fault in frontend has borken many downstream applications
(e.g., creduce).

It is tested on version 11.0.0 and 6.0.0.

$ ./clang++ test.cc
test.cc:4:28: error: C++ requires a type specifier for all declarations
            typeof({union {x = 0}})
                           ^
test.cc:4:33: error: expected ';' at end of declaration list
            typeof({union {x = 0}})
                                ^
                                ;
test.cc:4:34: error: expected ';' after union
            typeof({union {x = 0}})
                                 ^
                                 ;
test.cc:5:9: error: expected member name or ';' after declaration specifiers
        }
        ^
test.cc:5:10: error: expected ';' after union
        }
         ^
         ;
#0 0x00007fc75ec6d0ea llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x81e0ea)
#1 0x00007fc75ec6b366 llvm::sys::RunSignalHandlers()
(/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x81c366)
#2 0x00007fc75ec6b49b (/usr/lib/llvm-6.0/bin/../lib/libLLVM-6.0.so.1+0x81c49b)
#3 0x00007fc761efd8a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
#4 0x0000557648d5f4b7 clang::Sema::ActOnTagFinishDefinition(clang::Scope*,
clang::Decl*, clang::SourceRange) (/usr/lib/llvm-6.0/bin/clang+0xf994b7)
#5 0x0000557648b0cac0
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/usr/lib/llvm-6.0/bin/clang+0xd46ac0)
#6 0x0000557648b0f6c5 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/usr/lib/llvm-6.0/bin/clang+0xd496c5)
#7 0x0000557648ae9569
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/usr/lib/llvm-6.0/bin/clang+0xd23569)
#8 0x0000557648af7ec1
clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool,
clang::Parser::ForRangeInit*) (/usr/lib/llvm-6.0/bin/clang+0xd31ec1)
#9 0x0000557648af825b clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/lib/llvm-6.0/bin/clang+0xd3225b)
#10 0x0000557648b5cd15
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/lib/llvm-6.0/bin/clang+0xd96d15)
#11 0x0000557648b5d3c8
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*)
(/usr/lib/llvm-6.0/bin/clang+0xd973c8)
#12 0x0000557648b60e70 clang::Parser::ParseCompoundStatementBody(bool)
(/usr/lib/llvm-6.0/bin/clang+0xd9ae70)
#13 0x0000557648b63559 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/lib/llvm-6.0/bin/clang+0xd9d559)
#14 0x0000557648ad394b
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/lib/llvm-6.0/bin/clang+0xd0d94b)
#15 0x0000557648af4fdf clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/lib/llvm-6.0/bin/clang+0xd2efdf)
#16 0x0000557648acf0d1
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/lib/llvm-6.0/bin/clang+0xd090d1)
#17 0x0000557648acf729 (/usr/lib/llvm-6.0/bin/clang+0xd09729)
#18 0x0000557648ad59e5
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/lib/llvm-6.0/bin/clang+0xd0f9e5)
#19 0x0000557648ad69d9
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-6.0/bin/clang+0xd109d9)
#20 0x0000557648ad6ca0
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-6.0/bin/clang+0xd10ca0)
#21 0x0000557648acb7fb clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib/llvm-6.0/bin/clang+0xd057fb)
#22 0x000055764881ea27 clang::CodeGenAction::ExecuteAction()
(/usr/lib/llvm-6.0/bin/clang+0xa58a27)
#23 0x0000557648655b56 clang::FrontendAction::Execute()
(/usr/lib/llvm-6.0/bin/clang+0x88fb56)
#24 0x000055764861fbfc
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib/llvm-6.0/bin/clang+0x859bfc)
#25 0x0000557648700f13
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib/llvm-6.0/bin/clang+0x93af13)
#26 0x000055764821ee08 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-6.0/bin/clang+0x458e08)
#27 0x000055764820d807 main (/usr/lib/llvm-6.0/bin/clang+0x447807)
#28 0x00007fc75d50eb97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#29 0x000055764821c8aa _start (/usr/lib/llvm-6.0/bin/clang+0x4568aa)
Stack dump:
0.      Program arguments: /usr/lib/llvm-6.0/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name test.cc -mrelocation-model static
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/lib/llvm-6.0/lib/clang/6.0.0 -internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0
-internal-isystem
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward
-internal-isystem /usr/include/clang/6.0.0/include/ -internal-isystem
/usr/local/include -internal-isystem /usr/lib/llvm-6.0/lib/clang/6.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /data/xxx/docker_share/clang
-ferror-limit 19 -fmessage-length 119 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/test-0010a6.o -x c++ test.cc
1.      test.cc:7:1: current parser token '}'
2.      test.cc:1:12: parsing function body 'main'
3.      test.cc:1:12: in compound statement ('{}')
4.      test.cc:2:5: parsing struct/union/class body ''
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
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/test-ab98fb.cpp
clang: note: diagnostic msg: /tmp/test-ab98fb.sh
clang: note: diagnostic msg:

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


$ cat /tmp/test-ab98fb.cpp
# 1 "<built-in>"
# 1 "test.cc"
int main() {
    union {
        union {
            typeof({union {x = 0}})
        }
    }
}


$ cat /tmp/test-ab98fb.sh
# Crash reproducer for clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
# Driver args: "--driver-mode=g++" "test.cc"
# Original command:  "/usr/lib/llvm-6.0/bin/clang" "-cc1" "-triple"
"x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "test.cc"
"-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim"
"-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables"
"-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info"
"-debugger-tuning=gdb" "-resource-dir" "/usr/lib/llvm-6.0/lib/clang/6.0.0"
"-internal-isystem"
"/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0"
"-internal-isystem"
"/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0"
"-internal-isystem"
"/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0"
"-internal-isystem"
"/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward"
"-internal-isystem" "/usr/include/clang/6.0.0/include/" "-internal-isystem"
"/usr/local/include" "-internal-isystem"
"/usr/lib/llvm-6.0/lib/clang/6.0.0/include" "-internal-externc-isystem"
"/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include"
"-internal-externc-isystem" "/usr/include" "-fdeprecated-macro"
"-fdebug-compilation-dir" "/data/xxx/docker_share/clang" "-ferror-limit" "19"
"-fmessage-length" "119" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/test-0010a6.o"
"-x" "c++" "test.cc"
 "/usr/lib/llvm-6.0/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu"
"-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier"
"-discard-value-names" "-main-file-name" "test.cc" "-mrelocation-model"
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno"
"-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array"
"-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb"
"-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "119"
"-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++" "test-ab98fb.cpp"

-- 
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/20210214/9dcc4196/attachment.html>


More information about the llvm-bugs mailing list