Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Diagnostic crash with CL2.0 #43838

Open Quuxplusone opened 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR44868
Status NEW
Importance P normal
Reported by Marco Antognini (antognini.marco@gmail.com)
Reported on 2020-02-11 05:10:29 -0800
Last modified on 2020-02-11 05:54:59 -0800
Version trunk
Hardware PC Linux
CC anastasia.stulova@arm.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments crash2-6e6797.cl (102 bytes, text/x-opencl-src)
crash2-6e6797.sh (1827 bytes, application/x-shellscript)
Blocks
Blocked by
See also
The following program crashes Clang:

global float* cast_ptr() { return NULL; }
global uchar *x = dst_ptr;

Command line: clang -cl-std=CL2.0 crash2.cl

The crash is specific to CL2.0. For example, using CL1.2 doesn't crash.

Output:

crash2.cl:1:35: error: use of undeclared identifier 'NULL'
global float* cast_ptr() { return NULL; }
                                  ^
crash2.cl:2:8: error: unknown type name 'uchar'; did you mean 'char'?
global uchar *x = dst_ptr;
       ^~~~~
       char
crash2.cl:2:19: error: use of undeclared identifier 'dst_ptr'; did you mean
'cast_ptr'?
global uchar *x = dst_ptr;
                  ^~~~~~~
                  cast_ptr
crash2.cl:1:15: note: 'cast_ptr' declared here
global float* cast_ptr() { return NULL; }
              ^
clang-10: /work/checkouts/upstreams/llvm/llvm-
project/clang/include/clang/AST/Type.h:659: const
clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion
`!isNull() && "Cannot retrieve a NULL type pointer"' failed.
Stack dump:
0.      Program arguments: /volumes/ssd/builds/llvm/build/bin/clang-10 -cc1 -
triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-
name crash2.cl -mrelocation-model static -mthread-model posix -mframe-
pointer=all -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -
debugger-tuning=gdb -resource-dir
/volumes/ssd/builds/llvm/build/lib/clang/10.0.0 -internal-isystem
/usr/local/include -internal-isystem
/volumes/ssd/builds/llvm/build/lib/clang/10.0.0/include -internal-externc-
isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -
internal-externc-isystem /usr/include -fdebug-compilation-dir
/work/tests/ddk/MPGCOMP-10678 -ferror-limit 19 -fmessage-length 0 -cl-std=CL2.0
-fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-
diagnostics -faddrsig -o /tmp/crash2-7a6efb.o -x cl crash2.cl
1.      crash2.cl:2:26: current parser token ';'
 #0 0x00007f3f96d4d0db llvm::sys::PrintStackTrace(llvm::raw_ostream&) /work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:532:0
 #1 0x00007f3f96d4d16e PrintStackTraceSignalHandler(void*) /work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:593:0
 #2 0x00007f3f96d4b027 llvm::sys::RunSignalHandlers() /work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Signals.cpp:68:0
 #3 0x00007f3f96d4ca92 SignalHandler(int) /work/checkouts/upstreams/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:384:0
 #4 0x00007f3f9221bf20 (/lib/x86_64-linux-gnu/libc.so.6+0x3ef20)
 #5 0x00007f3f9221be97 raise /build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #6 0x00007f3f9221d801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #7 0x00007f3f9220d39a __assert_fail_base /build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #8 0x00007f3f9220d412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #9 0x00007f3f88a5f45c clang::QualType::getCommonPtr() const /work/checkouts/upstreams/llvm/llvm-project/clang/include/clang/AST/Type.h:659:0
#10 0x00007f3f88a60aa1 clang::QualType::getQualifiers() const
/work/checkouts/upstreams/llvm/llvm-project/clang/include/clang/AST/Type.h:6176:0
#11 0x00007f3f89029ae6
clang::Sema::DiagnoseAssignmentResult(clang::Sema::AssignConvertType,
clang::SourceLocation, clang::QualType, clang::QualType, clang::Expr*,
clang::Sema::AssignmentAction, bool*) /work/checkouts/upstreams/llvm/llvm-
project/clang/lib/Sema/SemaExpr.cpp:14701:0
#12 0x00007f3f892286e0 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Sema/SemaInit.cpp:8353:0
#13 0x00007f3f88c60aae clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool) /work/checkouts/upstreams/llvm/llvm-
project/clang/lib/Sema/SemaDecl.cpp:11741:0
#14 0x00007f3f8a244a3d
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2390:0
#15 0x00007f3f8a2436c9 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseDecl.cpp:2126:0
#16 0x00007f3f8a32851b
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:1096:0
#17 0x00007f3f8a3285f5
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:1111:0
#18 0x00007f3f8a327b55
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) /work/checkouts/upstreams/llvm/llvm-
project/clang/lib/Parse/Parser.cpp:931:0
#19 0x00007f3f8a326db2
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/Parser.cpp:682:0
#20 0x00007f3f8a22ae92 clang::ParseAST(clang::Sema&, bool, bool)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:157:0
#21 0x00007f3f937b2ded clang::ASTFrontendAction::ExecuteAction()
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1042:0
#22 0x00007f3f9492a37c clang::CodeGenAction::ExecuteAction()
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1089:0
#23 0x00007f3f937b274e clang::FrontendAction::Execute()
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:939:0
#24 0x00007f3f93732895
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:964:0
#25 0x00007f3f931e6267
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/work/checkouts/upstreams/llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:0
#26 0x0000557b0e00fd86 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /work/checkouts/upstreams/llvm/llvm-
project/clang/tools/driver/cc1_main.cpp:250:0
#27 0x0000557b0e0053a3 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef) /work/checkouts/upstreams/llvm/llvm-
project/clang/tools/driver/driver.cpp:309:0
#28 0x0000557b0e005a99 main /work/checkouts/upstreams/llvm/llvm-
project/clang/tools/driver/driver.cpp:382:0
#29 0x00007f3f921feb97 __libc_start_main /build/glibc-OTsEL5/glibc-
2.27/csu/../csu/libc-start.c:344:0
#30 0x0000557b0e003b7a _start (/volumes/ssd/builds/llvm/build/bin/clang-
10+0x41b7a)
clang-10: error: unable to execute command: Aborted (core dumped)
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
592dd459242946593920911936aea47461e0faaa)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/checkouts/upstreams/llvm/build/bin
Quuxplusone commented 4 years ago

Attached crash2-6e6797.cl (102 bytes, text/x-opencl-src): autogenerated input program

Quuxplusone commented 4 years ago

Attached crash2-6e6797.sh (1827 bytes, application/x-shellscript): autogenerated cc1 invocation script

Quuxplusone commented 4 years ago
I should also say that this crashes when using

clang -cc1 -cl-std=CL2.0 crash2.cl -finclude-default-header

as well. The only difference is that Clang doesn't complain, as expected, about
uchar and NULL.

crash2.cl:2:19: error: use of undeclared identifier 'dst_ptr'; did you mean
'cast_ptr'?
global uchar *x = dst_ptr;
                  ^~~~~~~
                  cast_ptr
crash2.cl:1:15: note: 'cast_ptr' declared here
global float* cast_ptr() { return NULL; }
              ^
clang: /work/checkouts/upstreams/llvm/llvm-
project/clang/include/clang/AST/Type.h:659: const
clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion
`!isNull() && "Cannot retrieve a NULL type pointer"' failed.