Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 720270 - sys-devel/clang-9.0.1: Crash on += operator with ISO/IEC 18037 types
Summary: sys-devel/clang-9.0.1: Crash on += operator with ISO/IEC 18037 types
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-01 11:52 UTC by Stefan Huber
Modified: 2021-03-06 16:18 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
The file that crashes clang (clang-segfault-accum-addeq.c,199 bytes, text/x-csrc)
2020-05-01 11:53 UTC, Stefan Huber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Huber 2020-05-01 11:52:09 UTC
The frontend of clang-9.0.1 crashes when compiling a C file that contains an invocation of the += operator on ISO/IEC 18037 types, like _Fract, _Accum or variants of these.

I could not reproduce this issue with clang-7.0.1-8 on Debian Buster or with clang-10.0.0 on Windows via msys2.

It should be noted that clang has no official support for ISO/IEC 18037 at the moment.

Reproducible: Always

Steps to Reproduce:
clang -c -ffixed-point -O0 -emit-llvm -save-temps clang-segfault-accum-addeq.c
Actual Results:  
Stack dump:
0.      Program arguments: /usr/lib/llvm/9/bin/clang-9 -cc1 -triple x86_64-pc-linux-gnu -emit-llvm-bc -emit-llvm-uselists -save-temps=cwd -disable-free -disable-llvm-verifier -discard-value-names -main-file-name clang-segfault-accum-addeq.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 -coverage-notes-file /home/shuber/tmp/clang-segfault-accum-addeq.gcno -resource-dir /usr/lib/llvm/9/bin/../../../../lib/clang/9.0.1 -O0 -ffixed-point -fdebug-compilation-dir /home/shuber/tmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -disable-llvm-passes -o clang-segfault-accum-addeq.tmp.bc -x cpp-output clang-segfault-accum-addeq.i 
1.      <eof> parser at end of file
2.      clang-segfault-accum-addeq.c:1:5: LLVM IR generation of declaration 'main'
3.      clang-segfault-accum-addeq.c:1:5: Generating code for declaration 'main'
 #0 0x00007f72a3b0ed2a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/llvm/9/bin/../lib64/libLLVMSupport.so.9+0x192d2a)
 #1 0x00007f72a3b0cfe4 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/9/bin/../lib64/libLLVMSupport.so.9+0x190fe4)
 #2 0x00007f72a3b0d165 (/usr/lib/llvm/9/bin/../lib64/libLLVMSupport.so.9+0x191165)
 #3 0x00007f72a21fa850 (/lib64/libc.so.6+0x33e2638850)
 #4 0x00007f72a462fd30 llvm::Value::getContext() const (/usr/lib/llvm/9/bin/../lib64/libLLVMCore.so.9+0x21ed30)
 #5 0x00007f72a45afb84 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, unsigned int, llvm::AtomicOrdering, unsigned char, llvm::Instruction*) (/usr/lib/llvm/9/bin/../lib64/libLLVMCore.so.9+0x19eb84)
 #6 0x00007f72a45afcf3 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, unsigned int, llvm::Instruction*) (/usr/lib/llvm/9/bin/../lib64/libLLVMCore.so.9+0x19ecf3)
 #7 0x00007f72a2e787ee clang::CodeGen::CodeGenFunction::EmitStoreOfScalar(llvm::Value*, clang::CodeGen::Address, bool, clang::QualType, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo, bool, bool) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x2187ee)
 #8 0x00007f72a2e8abeb clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue, clang::CodeGen::LValue, bool) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x22abeb)
 #9 0x00007f72a2ee44af (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x2844af)
#10 0x00007f72a2ee4777 (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x284777)
#11 0x00007f72a2edbd5f (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x27bd5f)
#12 0x00007f72a2edc550 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x27c550)
#13 0x00007f72a2e7343f clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x21343f)
#14 0x00007f72a2e882f6 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x2282f6)
#15 0x00007f72a2fde1c2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x37e1c2)
#16 0x00007f72a2fde791 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x37e791)
#17 0x00007f72a302c392 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x3cc392)
#18 0x00007f72a303689f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x3d689f)
#19 0x00007f72a306d1c6 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x40d1c6)
#20 0x00007f72a306aa15 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x40aa15)
#21 0x00007f72a306af83 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x40af83)
#22 0x00007f72a3070b7d clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x410b7d)
#23 0x00007f72a30e389f (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x48389f)
#24 0x00007f72a301a07d (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x3ba07d)
#25 0x00007f72a0cbe4ac clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm/9/bin/../lib64/../lib64/libclangParse.so.9+0x3b4ac)
#26 0x00007f72a301f860 clang::CodeGenAction::ExecuteAction() (/usr/lib/llvm/9/bin/../lib64/libclangCodeGen.so.9+0x3bf860)
#27 0x00007f72a296c399 clang::FrontendAction::Execute() (/usr/lib/llvm/9/bin/../lib64/libclangFrontend.so.9+0x106399)
#28 0x00007f72a291f90b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm/9/bin/../lib64/libclangFrontend.so.9+0xb990b)
#29 0x00007f72a2862ad7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm/9/bin/../lib64/libclangFrontendTool.so.9+0x5ad7)
#30 0x0000560993afe6c0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm/9/bin/clang-9+0x146c0)
#31 0x0000560993afa882 main (/usr/lib/llvm/9/bin/clang-9+0x10882)
#32 0x00007f72a21e5e1b __libc_start_main (/lib64/libc.so.6+0x33e2623e1b)
#33 0x0000560993afb35a _start (/usr/lib/llvm/9/bin/clang-9+0x1135a)
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.1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/9/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to  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/clang-segfault-accum-addeq-21259f.c
clang-9: note: diagnostic msg: /tmp/clang-segfault-accum-addeq-21259f.sh
clang-9: note: diagnostic msg: 

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


I could not report the bug upstream as their registration process on https://bugs.llvm.org/enter_bug.cgi is broken at the moment. (admin@lists.llvm.org bounces, no such user.)
Comment 1 Stefan Huber 2020-05-01 11:53:04 UTC
Created attachment 635482 [details]
The file that crashes clang
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-05-01 17:57:19 UTC
Indeed, I can reproduce with 10.0.0 as well.  I'm going to try the HEAD version, then pass it on to upstream.  Thanks for the report!
Comment 3 Stefan Huber 2020-05-01 18:41:27 UTC
Created a bug report upstream: https://bugs.llvm.org/show_bug.cgi?id=45771
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2020-05-01 19:42:18 UTC
I can't reproduce with clang-11.0.9999, so there might be a potential fix somewhere on master.
Comment 5 Stefan Huber 2020-05-03 10:56:27 UTC
I cannot reproduce the bug with clang-9.0.1 (commit c1a0a2133, tag llvmorg-9.0.1)  built from source with the configuration

cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm

Hence, this might be an issue only triggered by the source configuration provided by the Gentoo ebuild. (Also Debian's clang-7.0.1-8 and msys2's clang-10.0.0 does not show the bug.)
Comment 6 Sergei Trofimovich gentoo-dev 2020-05-03 12:21:33 UTC
It was fixed in https://reviews.llvm.org/D73184

"""
$ git bisect good
313461f6d8f91ac8abf2fa06e17b92127b050f06 is the first bad commit
commit 313461f6d8f91ac8abf2fa06e17b92127b050f06
Author: Bevin Hansson <bevin.hansson@ericsson.com>
Date:   Wed Jan 8 14:01:30 2020 +0100

    [CodeGen] Emit IR for compound assignment with fixed-point operands.

    Reviewers: rjmccall, leonardchan

    Subscribers: cfe-commits

    Tags: #clang

    Differential Revision: https://reviews.llvm.org/D73184

 clang/lib/CodeGen/CGExprScalar.cpp         |  20 +-
 clang/lib/Sema/SemaExpr.cpp                |   8 +
 clang/test/Frontend/fixed_point_compound.c | 374 +++++++++++++++++++++++++++++
 3 files changed, 396 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/Frontend/fixed_point_compound.c
"""
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-03-06 16:18:30 UTC
Closing bugs specific to llvm 9 that was removed today.