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
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: LLVM support project
Depends on:
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: ---

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

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/
 #1 0x00007f72a3b0cfe4 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/9/bin/../lib64/
 #2 0x00007f72a3b0d165 (/usr/lib/llvm/9/bin/../lib64/
 #3 0x00007f72a21fa850 (/lib64/
 #4 0x00007f72a462fd30 llvm::Value::getContext() const (/usr/lib/llvm/9/bin/../lib64/
 #5 0x00007f72a45afb84 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, unsigned int, llvm::AtomicOrdering, unsigned char, llvm::Instruction*) (/usr/lib/llvm/9/bin/../lib64/
 #6 0x00007f72a45afcf3 llvm::StoreInst::StoreInst(llvm::Value*, llvm::Value*, bool, unsigned int, llvm::Instruction*) (/usr/lib/llvm/9/bin/../lib64/
 #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/
 #8 0x00007f72a2e8abeb clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(clang::CodeGen::RValue, clang::CodeGen::LValue, bool) (/usr/lib/llvm/9/bin/../lib64/
 #9 0x00007f72a2ee44af (/usr/lib/llvm/9/bin/../lib64/
#10 0x00007f72a2ee4777 (/usr/lib/llvm/9/bin/../lib64/
#11 0x00007f72a2edbd5f (/usr/lib/llvm/9/bin/../lib64/
#12 0x00007f72a2edc550 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/usr/lib/llvm/9/bin/../lib64/
#13 0x00007f72a2e7343f clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/usr/lib/llvm/9/bin/../lib64/
#14 0x00007f72a2e882f6 clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/usr/lib/llvm/9/bin/../lib64/
#15 0x00007f72a2fde1c2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/usr/lib/llvm/9/bin/../lib64/
#16 0x00007f72a2fde791 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/usr/lib/llvm/9/bin/../lib64/
#17 0x00007f72a302c392 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/usr/lib/llvm/9/bin/../lib64/
#18 0x00007f72a303689f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/usr/lib/llvm/9/bin/../lib64/
#19 0x00007f72a306d1c6 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm/9/bin/../lib64/
#20 0x00007f72a306aa15 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/usr/lib/llvm/9/bin/../lib64/
#21 0x00007f72a306af83 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/usr/lib/llvm/9/bin/../lib64/
#22 0x00007f72a3070b7d clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (/usr/lib/llvm/9/bin/../lib64/
#23 0x00007f72a30e389f (/usr/lib/llvm/9/bin/../lib64/
#24 0x00007f72a301a07d (/usr/lib/llvm/9/bin/../lib64/
#25 0x00007f72a0cbe4ac clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm/9/bin/../lib64/../lib64/
#26 0x00007f72a301f860 clang::CodeGenAction::ExecuteAction() (/usr/lib/llvm/9/bin/../lib64/
#27 0x00007f72a296c399 clang::FrontendAction::Execute() (/usr/lib/llvm/9/bin/../lib64/
#28 0x00007f72a291f90b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm/9/bin/../lib64/
#29 0x00007f72a2862ad7 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm/9/bin/../lib64/
#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/
#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: 

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-9: note: diagnostic msg: 


I could not report the bug upstream as their registration process on is broken at the moment. ( 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:
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

$ git bisect good
313461f6d8f91ac8abf2fa06e17b92127b050f06 is the first bad commit
commit 313461f6d8f91ac8abf2fa06e17b92127b050f06
Author: Bevin Hansson <>
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:

 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.