Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WASM] Crash on -msimd128 when compiling ICU during "WebAssembly Instruction Selection" #63722

Open
hzuo opened this issue Jul 7, 2023 · 4 comments
Labels
backend:WebAssembly crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@hzuo
Copy link

hzuo commented Jul 7, 2023

Attempting to compile Skia with -msimd128 results in this error when ICU is included. Without -msimd128 everything compiles fine.

  FAILED: obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o
  em++ -MD -MF obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o.d -DU_COMMON_IMPLEMENTATION -DU_STATIC_IMPLEMENTATION -DU_ENABLE_DYLOAD=0 -DU_I18N_IMPLEMENTATION -D_XOPEN_SOURCE=0 -D__i386__ -DNDEBUG -DU_USING_ICU_NAMESPACE=0 -DU_DISABLE_RENAMING -DSK_USING_THIRD_PARTY_ICU  -w -Wno-attributes -ffp-contract=off -fstrict-aliasing -fPIC -fvisibility=hidden -O3 -O3 --target=wasm32-unknown-emscripten -fno-rtti -fno-exceptions -msign-ext -mnontrapping-fptoint -mbulk-memory -msimd128 -isystem /workspace/rust-skia/skia-bindings/skia/third_party/externals/icu/source/common -isystem /workspace/rust-skia/skia-bindings/skia/third_party/externals/icu/source/i18n -isystem /workspace/rust-skia/skia-bindings/skia/third_party/icu -std=c++17 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -frtti -c ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/umutablecptrie.cpp -o obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.	Program arguments: /base/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN --sysroot=/base/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -MD -MF obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o.d -DU_COMMON_IMPLEMENTATION -DU_STATIC_IMPLEMENTATION -DU_ENABLE_DYLOAD=0 -DU_I18N_IMPLEMENTATION -D_XOPEN_SOURCE=0 -D__i386__ -DNDEBUG -DU_USING_ICU_NAMESPACE=0 -DU_DISABLE_RENAMING -DSK_USING_THIRD_PARTY_ICU -w -Wno-attributes -ffp-contract=off -fstrict-aliasing -fPIC -fvisibility=hidden -O3 -O3 --target=wasm32-unknown-emscripten -fno-rtti -fno-exceptions -msign-ext -mnontrapping-fptoint -mbulk-memory -msimd128 -isystem /workspace/rust-skia/skia-bindings/skia/third_party/externals/icu/source/common -isystem /workspace/rust-skia/skia-bindings/skia/third_party/externals/icu/source/i18n -isystem /workspace/rust-skia/skia-bindings/skia/third_party/icu -std=c++17 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -frtti -c ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/umutablecptrie.cpp -o obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o
  1.	<eof> parser at end of file
  2.	Code generation
  3.	Running pass 'Function Pass Manager' on module '../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/umutablecptrie.cpp'.
  4.	Running pass 'WebAssembly Instruction Selection' on function '@umutablecptrie_buildImmutable'
   #0 0x000055ceef93e768 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/base/emsdk/upstream/bin/clang+++0x2bfd768)
   #1 0x000055ceef93c08e llvm::sys::RunSignalHandlers() (/base/emsdk/upstream/bin/clang+++0x2bfb08e)
   #2 0x000055ceef93da1e llvm::sys::CleanupOnSignal(unsigned long) (/base/emsdk/upstream/bin/clang+++0x2bfca1e)
   #3 0x000055ceef8aaad9 CrashRecoverySignalHandler(int) (.llvm.10467211991166094694) CrashRecoveryContext.cpp:0:0
   #4 0x00007fe232de8140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13140)
   #5 0x000055cef0b5816c llvm::SelectionDAG::getSExtOrTrunc(llvm::SDValue, llvm::SDLoc const&, llvm::EVT) (/base/emsdk/upstream/bin/clang+++0x3e1716c)
   #6 0x000055ceee778ca5 llvm::WebAssemblyTargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const WebAssemblyISelLowering.cpp:0:0
   #7 0x000055cef0a08bbd (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
   #8 0x000055cef0a076f0 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOpt::Level) (/base/emsdk/upstream/bin/clang+++0x3cc66f0)
   #9 0x000055cef0bad8db llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/base/emsdk/upstream/bin/clang+++0x3e6c8db)
  #10 0x000055cef0bacaed llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/base/emsdk/upstream/bin/clang+++0x3e6baed)
  #11 0x000055cef0ba9751 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/base/emsdk/upstream/bin/clang+++0x3e68751)
  #12 0x000055ceeee8bd88 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/base/emsdk/upstream/bin/clang+++0x214ad88)
  #13 0x000055ceef3d7e55 llvm::FPPassManager::runOnFunction(llvm::Function&) (/base/emsdk/upstream/bin/clang+++0x2696e55)
  #14 0x000055ceef3e1943 llvm::FPPassManager::runOnModule(llvm::Module&) (/base/emsdk/upstream/bin/clang+++0x26a0943)
  #15 0x000055ceef3d8ba6 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/base/emsdk/upstream/bin/clang+++0x2697ba6)
  #16 0x000055cef0172efa clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__2::unique_ptr<llvm::raw_pwrite_stream, std::__2::default_delete<llvm::raw_pwrite_stream>>) (/base/emsdk/upstream/bin/clang+++0x3431efa)
  #17 0x000055cef06d2310 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
  #18 0x000055cef14ee996 clang::ParseAST(clang::Sema&, bool, bool) (/base/emsdk/upstream/bin/clang+++0x47ad996)
  #19 0x000055cef05cf821 clang::FrontendAction::Execute() (/base/emsdk/upstream/bin/clang+++0x388e821)
  #20 0x000055cef05264e0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/base/emsdk/upstream/bin/clang+++0x37e54e0)
  #21 0x000055cef06cae96 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/base/emsdk/upstream/bin/clang+++0x3989e96)
  #22 0x000055ceee6daf9c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/base/emsdk/upstream/bin/clang+++0x1999f9c)
  #23 0x000055ceee6d7b61 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
  #24 0x000055cef0355159 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__2::optional<llvm::StringRef>>, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
  #25 0x000055ceef8aa85c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/base/emsdk/upstream/bin/clang+++0x2b6985c)
  #26 0x000055cef0354ae5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__2::optional<llvm::StringRef>>, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>*, bool*) const (/base/emsdk/upstream/bin/clang+++0x3613ae5)
  #27 0x000055cef030a46e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/base/emsdk/upstream/bin/clang+++0x35c946e)
  #28 0x000055cef033028c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*>>&) (/base/emsdk/upstream/bin/clang+++0x35ef28c)
  #29 0x000055ceee6d69ae clang_main(int, char**, llvm::ToolContext const&) (/base/emsdk/upstream/bin/clang+++0x19959ae)
  #30 0x000055ceee6e86c1 main (/base/emsdk/upstream/bin/clang+++0x19a76c1)
  #31 0x00007fe232a97d0a __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x23d0a)
  #32 0x000055ceee64ddea _start (/base/emsdk/upstream/bin/clang+++0x190cdea)
  clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
  clang version 17.0.0 (https://github.com/llvm/llvm-project f3b64887de61020c09404bfee97b2fadd30df10a)
  Target: wasm32-unknown-emscripten
  Thread model: posix
  InstalledDir: /base/emsdk/upstream/bin
  clang++: note: diagnostic msg:
  ********************

  PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
  Preprocessed source(s) and associated run script(s) are located at:
  clang++: note: diagnostic msg: /tmp/umutablecptrie-69ce6a.cpp
  clang++: note: diagnostic msg: /tmp/umutablecptrie-69ce6a.sh
  clang++: note: diagnostic msg:

  ********************
  em++: error: '/base/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -DEMSCRIPTEN --sysroot=/base/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -MD -MF obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o.d -DU_COMMON_IMPLEMENTATION -DU_STATIC_IMPLEMENTATION -DU_ENABLE_DYLOAD=0 -DU_I18N_IMPLEMENTATION -D_XOPEN_SOURCE=0 -D__i386__ -DNDEBUG -DU_USING_ICU_NAMESPACE=0 -DU_DISABLE_RENAMING -DSK_USING_THIRD_PARTY_ICU -w -Wno-attributes -ffp-contract=off -fstrict-aliasing -fPIC -fvisibility=hidden -O3 -O3 --target=wasm32-unknown-emscripten -fno-rtti -fno-exceptions -msign-ext -mnontrapping-fptoint -mbulk-memory -msimd128 -isystem /workspace/rust-skia/skia-bindings/skia/third_party/externals/icu/source/common -isystem /workspace/rust-skia/skia-bindings/skia/third_party/externals/icu/source/i18n -isystem /workspace/rust-skia/skia-bindings/skia/third_party/icu -std=c++17 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -frtti -c ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/umutablecptrie.cpp -o obj/third_party/externals/icu/source/common/libicu.umutablecptrie.o' failed (returned 1)
  [1124/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unistr_cnv.cpp
  [1125/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unames.cpp
  [1126/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unistr_case_locale.cpp
  [1127/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/uniset.cpp
  [1128/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/uniset_props.cpp
  [1129/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unorm.cpp
  [1130/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unistr.cpp
  [1131/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unistr_case.cpp
  [1132/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/uobject.cpp
  [1133/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unistr_props.cpp
  [1134/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unistr_titlecase_brkiter.cpp
  [1135/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/harfbuzz/src/hb-subset-plan.cc
  [1136/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/unormcmp.cpp
  [1137/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/ures_cnv.cpp
  [1138/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/uprops.cpp
  [1139/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/icu/source/common/uresbund.cpp
  [1140/1473] compile ../../../../../../../skia-bindings/skia/third_party/externals/harfbuzz/src/hb-subset.cc
  ninja: build stopped: subcommand failed.

Using the latest Emscripten with Clang 17.

root@6c328fbba732:/shared# emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.42 (6ede0b8fc1c979bb206148804bfb48b472ccc3da)
Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@6c328fbba732:/shared# clang --version
Debian clang version 17.0.0 (++20230705101038+49dfbc6efc64-1~exp1~20230705221154.752)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin

The files that the error message requested to be attached:
https://gist.github.com/hzuo/bc879349aaf12d643ea8cdeba4c1cec0

@hzuo
Copy link
Author

hzuo commented Jul 7, 2023

Maybe related to #55559

cc @tlively

@EugeneZelenko EugeneZelenko added backend:WebAssembly crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jul 7, 2023
@llvmbot
Copy link
Member

llvmbot commented Jul 7, 2023

@llvm/issue-subscribers-backend-webassembly

@hzuo
Copy link
Author

hzuo commented Jul 7, 2023

The files that the error message requested to be attached:
https://gist.github.com/hzuo/bc879349aaf12d643ea8cdeba4c1cec0

@tlively
Copy link
Collaborator

tlively commented Jul 7, 2023

For some reason I'm getting frontend compiler errors from that repro file. Are you able to reproduce the problem on Emscripten tot (tip of tree)? If so, could you try running the reproducer with -emit-llvm repro.bc instead of -c and sharing the resulting bitcode file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:WebAssembly crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

4 participants