emscripten-core / emscripten-core/emscripten

emscripten-llvm/clang 10: Segmentation fault with -ffast-math when compiling GraphViz (lab.c)

Open
#9,955 7 comments 0 reactions 0 assignees View on GitHub
LLVM wasm backend wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Not sure if this is the correct place to report the bug or if it belongs at bugs.llvm.

I try to compile Viz.js (GraphViz for the web) and the compiler segfaults while compiling "lab.c" of GraphViz. I reduced the problem to:

lab.c (reduced to code that segfaults):
```c
#include

double XYZEpsilon = 216./24389.;
double XYZKappa = 24389./27.;

static double PivotXYZ(double n){
if (n > XYZEpsilon) return pow(n, 1/3.);
return (XYZKappa*n + 16)/116;
}

int main(int argc, char** argv) {
return PivotXYZ((double)argc);
}
```

Compile line: When I remove -ffast-math it works
```
emcc -ffast-math lab.c
```

```
> emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.39.1 ((unknown revision))

> /usr/lib/emscripten-llvm/clang --version
clang version 10.0.0 (/srcdest/llvm-project 411f1885b655ea622fe124a87a6eadfd988d7a5e)
```

```
Stack dump:
0. Program arguments: /usr/lib/emscripten-llvm/clang-10 -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name lab.c -mrelocation-model static -mthread-model posix -mframe-pointer=none -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fno-trapping-math -ffp-contract=fast -ffast-math -ffinite-math-only -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -fvisibility hidden -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib/lib/clang/10.0.0 -D __EMSCRIPTEN_major__=1 -D __EMSCRIPTEN_minor__=39 -D __EMSCRIPTEN_tiny__=1 -D _LIBCPP_ABI_VERSION=2 -D unix -D __unix -D __unix__ -D EMSCRIPTEN -internal-isystem /usr/lib/lib/clang/10.0.0/include -internal-isystem /include/wasm32-emscripten -internal-isystem /include -Werror=implicit-function-declaration -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gnustep -fno-common -fdiagnostics-show-option -fcolor-diagnostics -nostdsysteminc -isystem/usr/lib/emscripten/system/include/libcxx -isystem/usr/lib/emscripten/system/lib/libcxxabi/include -isystem/usr/lib/emscripten/system/include/compat -isystem/usr/lib/emscripten/system/include -isystem/usr/lib/emscripten/system/include/libc -isystem/usr/lib/emscripten/system/lib/libc/musl/arch/emscripten -isystem/usr/lib/emscripten/system/local/include -isystem/usr/lib/emscripten/system/include/SDL -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_ubun2igx/lab_0.o -x c lab.c
1. parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'lab.c'.
4. Running pass 'WebAssembly Assembly Printer' on function '@PivotXYZ'
#0 0x000055f415994bcb llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/lib/emscripten-llvm/clang-10+0x18b9bcb)
#1 0x000055f415992a64 llvm::sys::RunSignalHandlers() (/usr/lib/emscripten-llvm/clang-10+0x18b7a64)
#2 0x000055f415992bf6 (/usr/lib/emscripten-llvm/clang-10+0x18b7bf6)
#3 0x00007fbd2fcaa930 __restore_rt (/usr/lib/libpthread.so.0+0x14930)
#4 0x000055f414c61379 llvm::getLibcallSignature(llvm::WebAssemblySubtarget const&, char const*, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&) (/usr/lib/emscripten-llvm/clang-10+0xb86379)
#5 0x000055f414c5dda8 (/usr/lib/emscripten-llvm/clang-10+0xb82da8)
#6 0x000055f414c5e14b (/usr/lib/emscripten-llvm/clang-10+0xb8314b)
#7 0x000055f414c57ed2 (/usr/lib/emscripten-llvm/clang-10+0xb7ced2)
#8 0x000055f41640f171 llvm::AsmPrinter::EmitFunctionBody() (/usr/lib/emscripten-llvm/clang-10+0x2334171)
#9 0x000055f414c5819d (/usr/lib/emscripten-llvm/clang-10+0xb7d19d)
#10 0x000055f415033116 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/emscripten-llvm/clang-10+0xf58116)
#11 0x000055f4153b2360 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/emscripten-llvm/clang-10+0x12d7360)
#12 0x000055f4153b23b2 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/emscripten-llvm/clang-10+0x12d73b2)
#13 0x000055f4153b1666 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/emscripten-llvm/clang-10+0x12d6666)
#14 0x000055f415bf56d2 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr >) (/usr/lib/emscripten-llvm/clang-10+0x1b1a6d2)
#15 0x000055f41676fd92 (/usr/lib/emscripten-llvm/clang-10+0x2694d92)
#16 0x000055f4174bc0a9 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/emscripten-llvm/clang-10+0x33e10a9)
#17 0x000055f41676d663 clang::CodeGenAction::ExecuteAction() (/usr/lib/emscripten-llvm/clang-10+0x2692663)
#18 0x000055f416167849 clang::FrontendAction::Execute() (/usr/lib/emscripten-llvm/clang-10+0x208c849)
#19 0x000055f41612294e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/emscripten-llvm/clang-10+0x204794e)
#20 0x000055f41623c1cd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/emscripten-llvm/clang-10+0x21611cd)
#21 0x000055f4149c7cab cc1_main(llvm::ArrayRef, char const*, void*) (/usr/lib/emscripten-llvm/clang-10+0x8eccab)
#22 0x000055f414968561 main (/usr/lib/emscripten-llvm/clang-10+0x88d561)
#23 0x00007fbd2f51f153 __libc_start_main (/usr/lib/libc.so.6+0x27153)
#24 0x000055f4149c5afe _start (/usr/lib/emscripten-llvm/clang-10+0x8eaafe)
clang-10: error: unable to execute command: Segmentation fault (core dumped)
clang-10: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 10.0.0 (/srcdest/llvm-project 411f1885b655ea622fe124a87a6eadfd988d7a5e)
Target: wasm32-unknown-emscripten
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.