[llvm-bugs] [Bug 38311] New: UDR: declare reduction on struct with implicit initializer: codegen segfault

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 25 12:28:48 PDT 2018


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

            Bug ID: 38311
           Summary: UDR: declare reduction on struct with implicit
                    initializer: codegen segfault
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: andrey.vul at gmail.com
                CC: llvm-bugs at lists.llvm.org

User-declared reduction on struct without explicit initializer causes a
segfault in clang 6.0.1.

Testcase:
int printf(const char *, ...);

struct S { int s; };
#pragma omp declare reduction(+: struct S: omp_out.s += omp_in.s) //
initializer(omp_priv = { .s = 0 })

int k[] = { 2, 3, 4, 5 };

int main() {
        struct S s;
        s.s = 0;
        #pragma omp parallel for reduction(+:s)
        for (int i = 0; i < (sizeof k / sizeof k[0]); ++i)
                s.s += k[i];
        printf("%d\n", s.s);
}

Reproducer script:
# Crash reproducer for clang version 6.0.1 (tags/RELEASE_601/final)
# Driver args: "-fopenmp" "t.c"
# Original command:  "/usr/lib64/llvm/6/bin/clang-6.0" "-cc1" "-triple"
"x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "t.c"
"-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/lib64/llvm/6/bin/../../../../lib/clang/6.0.1" "-internal-isystem"
"/usr/local/include" "-internal-isystem"
"/usr/lib64/llvm/6/bin/../../../../lib/clang/6.0.1/include"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-fdebug-compilation-dir" "/root" "-ferror-limit" "19"
"-fmessage-length" "176" "-fopenmp" "-fobjc-runtime=gcc"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "/tmp/t-b9e4e4.o" "-x"
"c" "t.c"
 "/usr/lib64/llvm/6/bin/clang-6.0" "-cc1" "-triple" "x86_64-pc-linux-gnu"
"-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier"
"-discard-value-names" "-main-file-name" "t.c" "-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" "-ferror-limit" "19"
"-fmessage-length" "176" "-fopenmp" "-fobjc-runtime=gcc"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c" "t-d12cd5.c"

Output:
#0 0x00007fb9cfea714a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/lib64/llvm/6/bin/../lib64/libLLVMSupport.so.6+0x10b14a)
#1 0x00007fb9cfea4f66 llvm::sys::RunSignalHandlers()
(/usr/lib64/llvm/6/bin/../lib64/libLLVMSupport.so.6+0x108f66)
#2 0x00007fb9cfea51eb
(/usr/lib64/llvm/6/bin/../lib64/libLLVMSupport.so.6+0x1091eb)
#3 0x00007fb9cd933820 (/lib64/libc.so.6+0x36820)
#4 0x00007fb9ced8ddc5
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x18adc5)
#5 0x00007fb9ced91a09
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x18ea09)
#6 0x00007fb9ced9328b clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x19028b)
#7 0x00007fb9ced853e6
clang::CodeGen::CodeGenFunction::EmitAnyExprToMem(clang::Expr const*,
clang::CodeGen::Address, clang::Qualifiers, bool)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x1823e6)
#8 0x00007fb9cee328bf
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x22f8bf)
#9 0x00007fb9cee3376d
clang::CodeGen::ReductionCodeGen::emitInitialization(clang::CodeGen::CodeGenFunction&,
unsigned int, clang::CodeGen::Address, clang::CodeGen::LValue,
llvm::function_ref<bool (clang::CodeGen::CodeGenFunction&)>)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x23076d)
#10 0x00007fb9cee7b31b
clang::CodeGen::CodeGenFunction::EmitOMPReductionClauseInit(clang::OMPExecutableDirective
const&, clang::CodeGen::CodeGenFunction::OMPPrivateScope&)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x27831b)
#11 0x00007fb9cee8e920
clang::CodeGen::CodeGenFunction::EmitOMPWorksharingLoop(clang::OMPLoopDirective
const&, clang::Expr*, llvm::function_ref<std::pair<clang::CodeGen::LValue,
clang::CodeGen::LValue> (clang::CodeGen::CodeGenFunction&,
clang::OMPExecutableDirective const&)> const&,
llvm::function_ref<std::pair<llvm::Value*, llvm::Value*>
(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&,
clang::CodeGen::Address, clang::CodeGen::Address)> const&)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x28b920)
#12 0x00007fb9cee8f5c8
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x28c5c8)
#13 0x00007fb9cee21804
clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&)
const (/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x21e804)
#14 0x00007fb9cee218bf
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x21e8bf)
#15 0x00007fb9cee9292d
clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt
const&) (/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x28f92d)
#16 0x00007fb9cee2e351
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x22b351)
#17 0x00007fb9cee2e51c
clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction(clang::OMPExecutableDirective
const&, clang::VarDecl const*, clang::OpenMPDirectiveKind,
clang::CodeGen::RegionCodeGenTy const&)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x22b51c)
#18 0x00007fb9cee8487d
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x28187d)
#19 0x00007fb9cee84e84
clang::CodeGen::CodeGenFunction::EmitOMPParallelForDirective(clang::OMPParallelForDirective
const&) (/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x281e84)
#20 0x00007fb9cee6a1a1 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2671a1)
#21 0x00007fb9cee6a4bb
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2674bb)
#22 0x00007fb9ceeb02c1
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&,
clang::Stmt const*)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2ad2c1)
#23 0x00007fb9ceeb876d
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2b576d)
#24 0x00007fb9ceed7dbd
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2d4dbd)
#25 0x00007fb9ceef5ef8
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2f2ef8)
#26 0x00007fb9ceef6e80
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2f3e80)
#27 0x00007fb9ceef7ebb
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2f4ebb)
#28 0x00007fb9cef64bb7
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x361bb7)
#29 0x00007fb9ceea0ea6
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x29dea6)
#30 0x00007fb9c88e1ca3 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib64/llvm/6/bin/../lib64/../lib64/libclangParse.so.6+0x2eca3)
#31 0x00007fb9ceea8ab6 clang::CodeGenAction::ExecuteAction()
(/usr/lib64/llvm/6/bin/../lib64/libclangCodeGen.so.6+0x2a5ab6)
#32 0x00007fb9ce5cae36 clang::FrontendAction::Execute()
(/usr/lib64/llvm/6/bin/../lib64/libclangFrontend.so.6+0xe2e36)
#33 0x00007fb9ce5856da
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib64/llvm/6/bin/../lib64/libclangFrontend.so.6+0x9d6da)
#34 0x00007fb9ce2e4f9a
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib64/llvm/6/bin/../lib64/libclangFrontendTool.so.6+0x3f9a)
#35 0x00005630beb6d4a8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib64/llvm/6/bin/clang-6.0+0x114a8)
#36 0x00005630beb69a0b main (/usr/lib64/llvm/6/bin/clang-6.0+0xda0b)
#37 0x00007fb9cd91eaee __libc_start_main (/lib64/libc.so.6+0x21aee)
#38 0x00005630beb6ae1a _start (/usr/lib64/llvm/6/bin/clang-6.0+0xee1a)
Stack dump:
0.      Program arguments: /usr/lib64/llvm/6/bin/clang-6.0 -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name t.c -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/lib64/llvm/6/bin/../../../../lib/clang/6.0.1 -internal-isystem
/usr/local/include -internal-isystem
/usr/lib64/llvm/6/bin/../../../../lib/clang/6.0.1/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdebug-compilation-dir /root -ferror-limit 19 -fmessage-length 176 -fopenmp
-fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o
/tmp/t-b9e4e4.o -x c t.c 
1.      <eof> parser at end of file
2.      t.c:8:5: LLVM IR generation of declaration 'main'
3.      t.c:8:5: Generating code for declaration 'main'
clang-6.0: error: unable to execute command: Segmentation fault
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.1 (tags/RELEASE_601/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/6/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to  and include the
crash backtrace, preprocessed source, and associated run script.
clang-6.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/t-d12cd5.c
clang-6.0: note: diagnostic msg: /tmp/t-d12cd5.sh
clang-6.0: 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/20180725/91d0ad2e/attachment.html>


More information about the llvm-bugs mailing list