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][OpenMP] Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. #69200

Closed
connglli opened this issue Oct 16, 2023 · 12 comments
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid good first issue https://github.com/llvm/llvm-project/contribute openmp

Comments

@connglli
Copy link

Compiler explorer: https://godbolt.org/z/5Wcz3KP8h.

The following program small.c triggers a crash in clang-18:

The small.c is quite similar to #69198 but with a different crash

% cat small.c
int c[-1];

void foo (){
  #pragma omp task depend(inout: c[:])
}



% clang -O0 -fopenmp-simd small.c
<source>:1:7: error: 'c' declared as an array with a negative size
    1 | int c[-1];
      |       ^~
clang: /root/llvm-project/clang/include/clang/AST/Type.h:752: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd <source>
1.  <source>:4:39: at annotation token
2.  <source>:3:12: parsing function body 'foo'
3.  <source>:3:12: in compound statement ('{}')
 #0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
 #1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
 #2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007efc03b50420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007efc0361300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007efc035f2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007efc035f2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007efc03603fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000000003a5419f clang::QualType::getNonReferenceType() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5419f)
 #9 0x00000000066bad0d clang::Sema::ActOnOpenMPDependClause(clang::OMPDependClause::DependDataTy const&, clang::Expr*, llvm::ArrayRef<clang::Expr*>, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66bad0d)
#10 0x00000000067080f0 clang::Sema::ActOnOpenMPVarListClause(llvm::omp::Clause, llvm::ArrayRef<clang::Expr*>, clang::OMPVarListLocTy const&, clang::Sema::OpenMPVarListDataTy&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67080f0)
#11 0x0000000005f5620f clang::Parser::ParseOpenMPVarListClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f5620f)
#12 0x0000000005f564a8 clang::Parser::ParseOpenMPClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f564a8)
#13 0x0000000005f625b8 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f625b8)
#14 0x0000000005f7f0e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7f0e4)
#15 0x0000000005f80f88 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f80f88)
#16 0x0000000005f81ec9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f81ec9)
#17 0x0000000005f837ea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f837ea)
#18 0x0000000005eb1501 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eb1501)
#19 0x0000000005ed8a18 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ed8a18)
#20 0x0000000005ea596b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea596b)
#21 0x0000000005ea609f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#22 0x0000000005eada44 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eada44)
#23 0x0000000005eae26d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eae26d)
#24 0x0000000005ea131a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea131a)
#25 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#26 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#27 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#28 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#29 0x0000000000befa56 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#30 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000000003fdc649 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#32 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#33 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#34 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#35 0x0000000003fa586d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa586d)
#36 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#37 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#38 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#39 0x00007efc035f4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#40 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)

Clang version:

clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0
@dtcxzyw dtcxzyw added openmp clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid and removed new issue labels Oct 16, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 16, 2023

@llvm/issue-subscribers-openmp

Author: None (connglli)

Compiler explorer: https://godbolt.org/z/5Wcz3KP8h.

The following program small.c triggers a crash in clang-18:

> The small.c is quite similar to #69198 but with a different crash

% cat small.c
int c[-1];

void foo (){
  #pragma omp task depend(inout: c[:])
}



% clang -O0 -fopenmp-simd small.c
&lt;source&gt;:1:7: error: 'c' declared as an array with a negative size
    1 | int c[-1];
      |       ^~
clang: /root/llvm-project/clang/include/clang/AST/Type.h:752: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() &amp;&amp; "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd &lt;source&gt;
1.  &lt;source&gt;:4:39: at annotation token
2.  &lt;source&gt;:3:12: parsing function body 'foo'
3.  &lt;source&gt;:3:12: in compound statement ('{}')
 #<!-- -->0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
 #<!-- -->1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
 #<!-- -->2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007efc03b50420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #<!-- -->4 0x00007efc0361300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #<!-- -->5 0x00007efc035f2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #<!-- -->6 0x00007efc035f2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #<!-- -->7 0x00007efc03603fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #<!-- -->8 0x0000000003a5419f clang::QualType::getNonReferenceType() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5419f)
 #<!-- -->9 0x00000000066bad0d clang::Sema::ActOnOpenMPDependClause(clang::OMPDependClause::DependDataTy const&amp;, clang::Expr*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66bad0d)
#<!-- -->10 0x00000000067080f0 clang::Sema::ActOnOpenMPVarListClause(llvm::omp::Clause, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::OMPVarListLocTy const&amp;, clang::Sema::OpenMPVarListDataTy&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67080f0)
#<!-- -->11 0x0000000005f5620f clang::Parser::ParseOpenMPVarListClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f5620f)
#<!-- -->12 0x0000000005f564a8 clang::Parser::ParseOpenMPClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f564a8)
#<!-- -->13 0x0000000005f625b8 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f625b8)
#<!-- -->14 0x0000000005f7f0e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7f0e4)
#<!-- -->15 0x0000000005f80f88 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f80f88)
#<!-- -->16 0x0000000005f81ec9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f81ec9)
#<!-- -->17 0x0000000005f837ea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f837ea)
#<!-- -->18 0x0000000005eb1501 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eb1501)
#<!-- -->19 0x0000000005ed8a18 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ed8a18)
#<!-- -->20 0x0000000005ea596b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea596b)
#<!-- -->21 0x0000000005ea609f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#<!-- -->22 0x0000000005eada44 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eada44)
#<!-- -->23 0x0000000005eae26d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eae26d)
#<!-- -->24 0x0000000005ea131a clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea131a)
#<!-- -->25 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#<!-- -->26 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#<!-- -->27 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#<!-- -->28 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#<!-- -->29 0x0000000000befa56 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#<!-- -->30 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->31 0x0000000003fdc649 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->32 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#<!-- -->33 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->34 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#<!-- -->35 0x0000000003fa586d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa586d)
#<!-- -->36 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#<!-- -->37 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#<!-- -->38 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#<!-- -->39 0x00007efc035f4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->40 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)

Clang version:

clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 16, 2023

@llvm/issue-subscribers-clang-frontend

Author: None (connglli)

Compiler explorer: https://godbolt.org/z/5Wcz3KP8h.

The following program small.c triggers a crash in clang-18:

> The small.c is quite similar to #69198 but with a different crash

% cat small.c
int c[-1];

void foo (){
  #pragma omp task depend(inout: c[:])
}



% clang -O0 -fopenmp-simd small.c
&lt;source&gt;:1:7: error: 'c' declared as an array with a negative size
    1 | int c[-1];
      |       ^~
clang: /root/llvm-project/clang/include/clang/AST/Type.h:752: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() &amp;&amp; "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd &lt;source&gt;
1.  &lt;source&gt;:4:39: at annotation token
2.  &lt;source&gt;:3:12: parsing function body 'foo'
3.  &lt;source&gt;:3:12: in compound statement ('{}')
 #<!-- -->0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
 #<!-- -->1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
 #<!-- -->2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007efc03b50420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #<!-- -->4 0x00007efc0361300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #<!-- -->5 0x00007efc035f2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #<!-- -->6 0x00007efc035f2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #<!-- -->7 0x00007efc03603fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #<!-- -->8 0x0000000003a5419f clang::QualType::getNonReferenceType() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5419f)
 #<!-- -->9 0x00000000066bad0d clang::Sema::ActOnOpenMPDependClause(clang::OMPDependClause::DependDataTy const&amp;, clang::Expr*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66bad0d)
#<!-- -->10 0x00000000067080f0 clang::Sema::ActOnOpenMPVarListClause(llvm::omp::Clause, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::OMPVarListLocTy const&amp;, clang::Sema::OpenMPVarListDataTy&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67080f0)
#<!-- -->11 0x0000000005f5620f clang::Parser::ParseOpenMPVarListClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f5620f)
#<!-- -->12 0x0000000005f564a8 clang::Parser::ParseOpenMPClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f564a8)
#<!-- -->13 0x0000000005f625b8 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f625b8)
#<!-- -->14 0x0000000005f7f0e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7f0e4)
#<!-- -->15 0x0000000005f80f88 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f80f88)
#<!-- -->16 0x0000000005f81ec9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f81ec9)
#<!-- -->17 0x0000000005f837ea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f837ea)
#<!-- -->18 0x0000000005eb1501 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eb1501)
#<!-- -->19 0x0000000005ed8a18 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ed8a18)
#<!-- -->20 0x0000000005ea596b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea596b)
#<!-- -->21 0x0000000005ea609f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#<!-- -->22 0x0000000005eada44 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eada44)
#<!-- -->23 0x0000000005eae26d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eae26d)
#<!-- -->24 0x0000000005ea131a clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea131a)
#<!-- -->25 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#<!-- -->26 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#<!-- -->27 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#<!-- -->28 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#<!-- -->29 0x0000000000befa56 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#<!-- -->30 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->31 0x0000000003fdc649 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->32 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#<!-- -->33 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->34 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#<!-- -->35 0x0000000003fa586d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa586d)
#<!-- -->36 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#<!-- -->37 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#<!-- -->38 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#<!-- -->39 0x00007efc035f4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->40 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)

Clang version:

clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0

@shiltian shiltian changed the title Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. [Clang][OpenMP] Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed. Oct 27, 2023
@shiltian shiltian added the good first issue https://github.com/llvm/llvm-project/contribute label Oct 27, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 27, 2023

@llvm/issue-subscribers-good-first-issue

Author: None (connglli)

Compiler explorer: https://godbolt.org/z/5Wcz3KP8h.

The following program small.c triggers a crash in clang-18:

> The small.c is quite similar to #69198 but with a different crash

% cat small.c
int c[-1];

void foo (){
  #pragma omp task depend(inout: c[:])
}



% clang -O0 -fopenmp-simd small.c
&lt;source&gt;:1:7: error: 'c' declared as an array with a negative size
    1 | int c[-1];
      |       ^~
clang: /root/llvm-project/clang/include/clang/AST/Type.h:752: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() &amp;&amp; "Cannot retrieve a NULL type pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd &lt;source&gt;
1.  &lt;source&gt;:4:39: at annotation token
2.  &lt;source&gt;:3:12: parsing function body 'foo'
3.  &lt;source&gt;:3:12: in compound statement ('{}')
 #<!-- -->0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
 #<!-- -->1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
 #<!-- -->2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007efc03b50420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #<!-- -->4 0x00007efc0361300b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #<!-- -->5 0x00007efc035f2859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #<!-- -->6 0x00007efc035f2729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #<!-- -->7 0x00007efc03603fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #<!-- -->8 0x0000000003a5419f clang::QualType::getNonReferenceType() const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5419f)
 #<!-- -->9 0x00000000066bad0d clang::Sema::ActOnOpenMPDependClause(clang::OMPDependClause::DependDataTy const&amp;, clang::Expr*, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66bad0d)
#<!-- -->10 0x00000000067080f0 clang::Sema::ActOnOpenMPVarListClause(llvm::omp::Clause, llvm::ArrayRef&lt;clang::Expr*&gt;, clang::OMPVarListLocTy const&amp;, clang::Sema::OpenMPVarListDataTy&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67080f0)
#<!-- -->11 0x0000000005f5620f clang::Parser::ParseOpenMPVarListClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f5620f)
#<!-- -->12 0x0000000005f564a8 clang::Parser::ParseOpenMPClause(llvm::omp::Directive, llvm::omp::Clause, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f564a8)
#<!-- -->13 0x0000000005f625b8 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f625b8)
#<!-- -->14 0x0000000005f7f0e4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f7f0e4)
#<!-- -->15 0x0000000005f80f88 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&lt;clang::Stmt*, 32u&gt;&amp;, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f80f88)
#<!-- -->16 0x0000000005f81ec9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f81ec9)
#<!-- -->17 0x0000000005f837ea clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5f837ea)
#<!-- -->18 0x0000000005eb1501 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&amp;, clang::Parser::ParsedTemplateInfo const&amp;, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eb1501)
#<!-- -->19 0x0000000005ed8a18 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&amp;, clang::DeclaratorContext, clang::ParsedAttributes&amp;, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ed8a18)
#<!-- -->20 0x0000000005ea596b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec&amp;, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea596b)
#<!-- -->21 0x0000000005ea609f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#<!-- -->22 0x0000000005eada44 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&amp;, clang::ParsedAttributes&amp;, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eada44)
#<!-- -->23 0x0000000005eae26d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&lt;clang::DeclGroupRef&gt;&amp;, clang::Sema::ModuleImportState&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5eae26d)
#<!-- -->24 0x0000000005ea131a clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea131a)
#<!-- -->25 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#<!-- -->26 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#<!-- -->27 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#<!-- -->28 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#<!-- -->29 0x0000000000befa56 cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#<!-- -->30 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->31 0x0000000003fdc649 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->32 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#<!-- -->33 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->34 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#<!-- -->35 0x0000000003fa586d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa586d)
#<!-- -->36 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#<!-- -->37 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#<!-- -->38 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#<!-- -->39 0x00007efc035f4083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#<!-- -->40 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)

Clang version:

clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0

@gogo2464
Copy link

gogo2464 commented Oct 27, 2023

@connglli This sounds to be a good first issue. I would like to be assigned to this issue. Could you assign me please?

Could I get the full small.c file for a reproducible example please?

@shiltian
Copy link
Contributor

Thanks for working on that. I think the code shown here and https://godbolt.org/z/5Wcz3KP8h is sufficient for the reproducer.

@gogo2464
Copy link

Should I only fix the crash and let the error on -1 or should I also allow the -1?

@shiltian
Copy link
Contributor

The error on -1 has already been caught. The crash is the issue here. By no means a compiler can crash upon a code error.

@InfiniteVerma
Copy link

Hi @shiltian , I'd like to work on this.

@InfiniteVerma
Copy link

I followed the crash dump and noticed that the call reaches to this line:

ExprTy = BaseType->getPointeeType();
ExprTy = ExprTy.getNonReferenceType();

The crash happens on the second line above. As a test, I overwrote the getNonReferenceType(); line with continue; and clang exited without crashing.

Can someone please give me some pointers on how to progress on this? As I understand, we need to do a -ve size check similar to this check and eventually hit a continue;

@jhuber6
Copy link
Contributor

jhuber6 commented Jan 5, 2024

I followed the crash dump and noticed that the call reaches to this line:

ExprTy = BaseType->getPointeeType();
ExprTy = ExprTy.getNonReferenceType();

The crash happens on the second line above. As a test, I overwrote the getNonReferenceType(); line with continue; and clang exited without crashing.

Can someone please give me some pointers on how to progress on this? As I understand, we need to do a -ve size check similar to this check and eventually hit a continue;

Most likely we just need to be more explicit with the special case this creates. It seems this is already handled as an error by some other semantic analysis, so the OpenMP checks just need to stop crashing. I would suggest using -Xclang -ast-dump or just the dump() methods on the types to figure out what it's seeing before it crashes and just making a check to avoid it.

InfiniteVerma added a commit to InfiniteVerma/llvm-project that referenced this issue Jan 5, 2024
@InfiniteVerma
Copy link

Ping

jhuber6 pushed a commit that referenced this issue Feb 7, 2024
…r"' fail. (#81015)

Fixes : #69085 , #69200

**PR SUMMARY**: "Added Null check for negative sized array and a test
for the same"
@Sh0g0-1758
Copy link
Contributor

I think we can close this issue also now.

@shiltian shiltian closed this as completed Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash-on-invalid good first issue https://github.com/llvm/llvm-project/contribute openmp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants