[llvm-bugs] [Bug 47532] New: Local variable used inside critical clause inside task clause crashes clang 12

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 14 16:17:04 PDT 2020


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

            Bug ID: 47532
           Summary: Local variable used inside critical clause inside task
                    clause crashes clang 12
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: fmorac at udel.edu
                CC: llvm-bugs at lists.llvm.org

Created attachment 23961
  --> https://bugs.llvm.org/attachment.cgi?id=23961&action=edit
Run script created when clang crashed

Description: 
Clang 12 crashes when a variable defined inside a parallel region is used
within the context of a critical region inside a task region.

===========================================================
Test case: test.c

int main() {
#pragma omp parallel
  {
    int i = 0;
#pragma omp task
    {
#pragma omp critical
      ++i;
    }
  }
  return 0;
}
===========================================================

Steps to reproduce:
  1. clang-12 test.c -fopenmp

Note: This issue doesn't happen on clang-9.

Additional information:

OS: Debian "bullseye" (with all packages up to date with respect to the 22:43
GMT 09/14/2020 time mark)
Clang version: 12.0.0-++20200914111122+119e57be762-1~exp1~20200914091805.3484

===========================================================
Preprocessed source created by clang:
test-755c90.c:
# 1 "<built-in>"
# 1 "test.c"
int main() {
#pragma omp parallel
  {
    int i = 0;
#pragma omp task
    {
#pragma omp critical
      ++i;
    }
  }
  return 0;
}
============================================
Clang stacktrace:

Stack dump:
0.      Program arguments: /usr/lib/llvm-12/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name test.c
-mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/usr/lib/llvm-12/lib/clang/12.0.0 -internal-isystem /usr/local/include
-internal-isystem /usr/lib/llvm-12/lib/clang/12.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /home/fabian -ferror-limit 19 -fopenmp
-fopenmp-cuda-parallel-target-regions -fgnuc-version=4.2.1 -fcolor-diagnostics
-faddrsig -o /tmp/test-9d4275.o -x c test.c 
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      test.c:1:5: Generating code for declaration 'main'
4.      test.c:3:3: LLVM IR generation of compound statement ('{}')
5.      test.c:6:5: LLVM IR generation of compound statement ('{}')
 #0 0x00007f0f6cf147c3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/lib/x86_64-linux-gnu/libLLVM-12.so.1+0xb9e7c3)
 #1 0x00007f0f6cf12b70 llvm::sys::RunSignalHandlers()
(/lib/x86_64-linux-gnu/libLLVM-12.so.1+0xb9cb70)
 #2 0x00007f0f6cf14df5 (/lib/x86_64-linux-gnu/libLLVM-12.so.1+0xb9edf5)
 #3 0x00007f0f74191140 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #4 0x00007f0f72c22530
clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x17c8530)
 #5 0x00007f0f72c17e89 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr
const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x17bde89)
 #6 0x00007f0f72c5decb (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1803ecb)
 #7 0x00007f0f72c56752
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x17fc752)
 #8 0x00007f0f72c17c48 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x17bdc48)
 #9 0x00007f0f72c17bf9
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x17bdbf9)
#10 0x00007f0f72d518ea clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f78ea)
#11 0x00007f0f72d12314 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18b8314)
#12 0x00007f0f72d0179b
clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&,
llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18a779b)
#13 0x00007f0f72ce7036
clang::CodeGen::CGOpenMPRuntime::emitCriticalRegion(clang::CodeGen::CodeGenFunction&,
llvm::StringRef, clang::CodeGen::RegionCodeGenTy const&, clang::SourceLocation,
clang::Expr const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x188d036)
#14 0x00007f0f72d72a67
clang::CodeGen::CodeGenFunction::EmitOMPCriticalDirective(clang::OMPCriticalDirective
const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1918a67)
#15 0x00007f0f72d51aa7 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f7aa7)
#16 0x00007f0f72d5b61c
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x190161c)
#17 0x00007f0f72d5ab78
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1900b78)
#18 0x00007f0f72d51f26
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f7f26)
#19 0x00007f0f72d5180e clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f780e)
#20 0x00007f0f72cdd303
clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&)
const (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1883303)
#21 0x00007f0f72d89fa7 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x192ffa7)
#22 0x00007f0f72d12314 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18b8314)
#23 0x00007f0f72d5ee56
clang::CodeGen::CodeGenFunction::GenerateCapturedStmtFunction(clang::CapturedStmt
const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1904e56)
#24 0x00007f0f72ce2062
clang::CodeGen::CGOpenMPRuntime::emitTaskOutlinedFunction(clang::OMPExecutableDirective
const&, clang::VarDecl const*, clang::VarDecl const*, clang::VarDecl const*,
llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool, unsigned
int&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1888062)
#25 0x00007f0f72d74649
clang::CodeGen::CodeGenFunction::EmitOMPTaskBasedDirective(clang::OMPExecutableDirective
const&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&,
llvm::function_ref<void (clang::CodeGen::CodeGenFunction&, llvm::Function*,
clang::CodeGen::OMPTaskDataTy const&)> const&, clang::CodeGen::OMPTaskDataTy&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x191a649)
#26 0x00007f0f72d75bb5
clang::CodeGen::CodeGenFunction::EmitOMPTaskDirective(clang::OMPTaskDirective
const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x191bbb5)
#27 0x00007f0f72d51d77 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f7d77)
#28 0x00007f0f72d5b61c
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x190161c)
#29 0x00007f0f72d5ab78
clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&,
bool, clang::CodeGen::AggValueSlot)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1900b78)
#30 0x00007f0f72d51f26
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f7f26)
#31 0x00007f0f72d5180e clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f780e)
#32 0x00007f0f72d81355 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1927355)
#33 0x00007f0f72d12314 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18b8314)
#34 0x00007f0f72d609e2
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt
const&, clang::SourceLocation)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x19069e2)
#35 0x00007f0f72ce1d0f (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1887d0f)
#36 0x00007f0f72ce1b1a
clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction(clang::OMPExecutableDirective
const&, clang::VarDecl const*, llvm::omp::Directive,
clang::CodeGen::RegionCodeGenTy const&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1887b1a)
#37 0x00007f0f72d6923d (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x190f23d)
#38 0x00007f0f72d68d64
clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective
const&) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x190ed64)
#39 0x00007f0f72d51c87 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x18f7c87)
#40 0x00007f0f72d5b61c
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x190161c)
#41 0x00007f0f72da72c8
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x194d2c8)
#42 0x00007f0f72da7b7c
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x194db7c)
#43 0x00007f0f72dbec9f
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1964c9f)
#44 0x00007f0f72db9792
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x195f792)
#45 0x00007f0f72db0291 clang::CodeGen::CodeGenModule::EmitDeferred()
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1956291)
#46 0x00007f0f72daf588 clang::CodeGen::CodeGenModule::Release()
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1955588)
#47 0x00007f0f72e30204 (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x19d6204)
#48 0x00007f0f72d9e9fa (/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x19449fa)
#49 0x00007f0f71e59fc4 clang::ParseAST(clang::Sema&, bool, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x9fffc4)
#50 0x00007f0f73433848 clang::FrontendAction::Execute()
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1fd9848)
#51 0x00007f0f733e9741
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x1f8f741)
#52 0x00007f0f734996cd
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.12+0x203f6cd)
#53 0x00000000004132ad cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-12/bin/clang+0x4132ad)
#54 0x00000000004116de (/usr/lib/llvm-12/bin/clang+0x4116de)
#55 0x00000000004114ef main (/usr/lib/llvm-12/bin/clang+0x4114ef)
#56 0x00007f0f6beaacca __libc_start_main ./csu/../csu/libc-start.c:308:16
#57 0x000000000040e8aa _start (/usr/lib/llvm-12/bin/clang+0x40e8aa)
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
Debian clang version
12.0.0-++20200914111122+119e57be762-1~exp1~20200914091805.3484
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: 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/20200914/e0702dc1/attachment-0001.html>


More information about the llvm-bugs mailing list