Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

-Wdocumentation crash in Sema::checkReturnsCommand for typedef'ed function pointers #43845

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR44876
Status NEW
Importance P normal
Reported by Christopher Lapkowski (lapkow@synopsys.com)
Reported on 2020-02-11 12:36:56 -0800
Last modified on 2020-02-18 14:39:37 -0800
Version unspecified
Hardware All All
CC llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk, thonerma@synopsys.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The following test causes a crash with -Wdocumentation

typedef int funcptr();
/**
 * @return something
 */
funcptr *pFunc;

clang -Wdocumentation -c reproducer.cpp
Quuxplusone commented 4 years ago
Verified that this issue reproduces for Clang versions 5.0.0 through 9.0.0.

Here is the stack dump for Clang 9:

$ clang -c -Wdocumentation t.cpp
Stack dump:
0.      Program arguments: /slowfs/sig-sat/home/thonerma/products/linux-
x86/clang-9.0.0-opt/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-
file-name t.cpp -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 -coverage-
notes-file /data00/home/thonerma/prevent-surrey/tmp/t.gcno -resource-dir
/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-
opt/lib/clang/9.0.0 -internal-isystem /usr/lib/gcc/x86_64-linux-
gnu/7.4.0/../../../../include/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-
linux-gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0 -internal-
isystem /usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-
gnu/c++/7.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-
gnu/7.4.0/../../../../include/c++/7.4.0/backward -internal-isystem
/usr/local/include -internal-isystem /slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/lib/clang/9.0.0/include -
internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-
isystem /include -internal-externc-isystem /usr/include -Wdocumentation -
fdeprecated-macro -fdebug-compilation-dir /data00/home/thonerma/prevent-
surrey/tmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-
exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -faddrsig
-o t.o -x c++ t.cpp
1.      <eof> parser at end of file
 #0 0x0000000001aac72d PrintStackTraceSignalHandler(void*) (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x1aac72d)
 #1 0x0000000001aaa5ae llvm::sys::RunSignalHandlers() (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x1aaa5ae)
 #2 0x0000000001aacb28 SignalHandler(int) (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x1aacb28)
 #3 0x0000000001c00500 __restore_rt (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x1c00500)
 #4 0x00000000037f3669 clang::comments::Sema::checkReturnsCommand(clang::comments::BlockCommandComment const*) (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x37f3669)
 #5 0x00000000037f2dfc clang::comments::Sema::actOnBlockCommandFinish(clang::comments::BlockCommandComment*, clang::comments::ParagraphComment*) (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x37f2dfc)
 #6 0x00000000037efd55 clang::comments::Parser::parseBlockCommand() (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x37efd55)
 #7 0x00000000037f07f4 clang::comments::Parser::parseParagraphOrBlockCommand() (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x37f07f4)
 #8 0x00000000037f2542 clang::comments::Parser::parseFullComment() (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x37f2542)
 #9 0x0000000003753205 clang::RawComment::parse(clang::ASTContext const&, clang::Preprocessor const*, clang::Decl const*) const (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x3753205)
#10 0x00000000035309a4 clang::ASTContext::getCommentForDecl(clang::Decl const*,
clang::Preprocessor const*) const (/slowfs/sig-sat/home/thonerma/products/linux-
x86/clang-9.0.0-opt/bin/clang-9+0x35309a4)
#11 0x0000000002f5c326
clang::Sema::ActOnDocumentableDecls(llvm::ArrayRef<clang::Decl*>) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2f5c326)
#12 0x0000000002f5bfa0
clang::Sema::BuildDeclaratorGroup(llvm::MutableArrayRef<clang::Decl*>)
(/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2f5bfa0)
#13 0x0000000002f5b8e6 clang::Sema::FinalizeDeclaratorGroup(clang::Scope*,
clang::DeclSpec const&, llvm::ArrayRef<clang::Decl*>) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2f5b8e6)
#14 0x0000000002d65078 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2d65078)
#15 0x0000000002d4bdb8
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2d4bdb8)
#16 0x0000000002d4b8c5
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2d4b8c5)
#17 0x0000000002d4a8d5
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/slowfs/sig-sat/home/thonerma/products/linux-
x86/clang-9.0.0-opt/bin/clang-9+0x2d4a8d5)
#18 0x0000000002d48b0d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2d48b0d)
#19 0x0000000002d44095 clang::ParseAST(clang::Sema&, bool, bool) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2d44095)
#20 0x00000000020b46b7 clang::FrontendAction::Execute() (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x20b46b7)
#21 0x000000000205eaff
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x205eaff)
#22 0x0000000002145348
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x2145348)
#23 0x0000000000489bcf cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-
opt/bin/clang-9+0x489bcf)
#24 0x0000000000487866 main (/slowfs/sig-sat/home/thonerma/products/linux-
x86/clang-9.0.0-opt/bin/clang-9+0x487866)
#25 0x0000000003a45a59 __libc_start_main (/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9+0x3a45a59)
#26 0x0000000000484cfa _start (/slowfs/sig-sat/home/thonerma/products/linux-
x86/clang-9.0.0-opt/bin/clang-9+0x484cfa)
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 (tags/RELEASE_900/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /u/thonerma/sig-sat-home/products/linux-x86/clang-9.0.0-opt/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/t-d297c0.cpp
clang-9: note: diagnostic msg: /tmp/t-d297c0.sh
clang-9: note: diagnostic msg:

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

$ cat /tmp/t-d297c0.cpp
# 1 "<built-in>"
# 1 "t.cpp"
typedef int funcptr();
/**
 * @return something
 */
funcptr *pFunc;

$ cat /tmp/t-d297c0.sh
# Crash reproducer for clang version 9.0.0 (tags/RELEASE_900/final)
# Driver args: "-c" "-Wdocumentation" "t.cpp"
# Original command:  "/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-
9.0.0-opt/bin/clang-9" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj"
"-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-
main-file-name" "t.cpp" "-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" "-coverage-notes-file" "/data00/home/thonerma/prevent-
surrey/tmp/t.gcno" "-resource-dir" "/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/lib/clang/9.0.0" "-
internal-isystem" "/usr/lib/gcc/x86_64-linux-
gnu/7.4.0/../../../../include/c++/7.4.0" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/x86_64-linux-
gnu/c++/7.4.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-
gnu/7.4.0/../../../../include/x86_64-linux-gnu/c++/7.4.0" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/7.4.0/../../../../include/c++/7.4.0/backward" "-
internal-isystem" "/usr/local/include" "-internal-isystem" "/slowfs/sig-
sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/lib/clang/9.0.0/include" "-
internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-
isystem" "/include" "-internal-externc-isystem" "/usr/include" "-
Wdocumentation" "-fdeprecated-macro" "-fdebug-compilation-dir"
"/data00/home/thonerma/prevent-surrey/tmp" "-ferror-limit" "19" "-fmessage-
length" "0" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-
fdiagnostics-show-option" "-fcolor-diagnostics" "-faddrsig" "-o" "t.o" "-x"
"c++" "t.cpp"
 "/slowfs/sig-sat/home/thonerma/products/linux-x86/clang-9.0.0-opt/bin/clang-9" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "t.cpp" "-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" "-coverage-notes-file" "/data00/home/thonerma/prevent-surrey/tmp/t.gcno" "-Wdocumentation" "-fdeprecated-macro" "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-faddrsig" "-x" "c++" "t-d297c0.cpp"