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

[BUG] clang++ backend crash #1377

Closed
fmalita opened this issue Nov 18, 2020 · 9 comments
Closed

[BUG] clang++ backend crash #1377

fmalita opened this issue Nov 18, 2020 · 9 comments
Assignees
Labels

Comments

@fmalita
Copy link

fmalita commented Nov 18, 2020

Description

armv7a-linux-androideabi30-clang++ '-mfpu=neon' -mthumb -fomit-frame-pointer -Oz '-std=gnu++17' -DSK_ENABLE_SKSL_INTERPRETER -I. -c src/sksl/SkSLByteCode.cpp -o /tmp/SkSLByteCode.o
fatal error: error in backend: Error while trying to spill LR from class GPR: Cannot scavenge register without an emergency spill slot!
PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7a-linux-androideabi30 -mfpu=neon -mthumb -fomit-frame-pointer -Oz -std=gnu++17 -DSK_ENABLE_SKSL_INTERPRETER -I. -c src/sksl/SkSLByteCode.cpp -o /tmp/SkSLByteCode.o 
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'src/sksl/SkSLByteCode.cpp'.
4.	Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@_ZN4SkSL11Interpreter10Inverse3x3EPNS0_6VValueE'
 #0 0x0000000003456ac5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3456ac5)
 #1 0x0000000003456960 llvm::sys::RunSignalHandlers() (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3456960)
 #2 0x0000000003425250 (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x3425250)
 #3 0x000000000342520b (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x342520b)
 #4 0x0000000002ec4cfe (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2ec4cfe)
 #5 0x0000000002ec4c67 (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2ec4c67)
 #6 0x0000000002ecc81f llvm::report_fatal_error(llvm::Twine const&, bool) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2ecc81f)
 #7 0x0000000002ec8787 (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2ec8787)
 #8 0x00000000031c675d (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x31c675d)
 #9 0x0000000002a7cf26 llvm::RegScavenger::scavengeRegisterBackwards(llvm::TargetRegisterClass const&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, bool, int, bool) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2a7cf26)
#10 0x0000000002a7cd53 (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2a7cd53)
#11 0x0000000002a7c72a (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2a7c72a)
#12 0x0000000002a78fd3 llvm::scavengeFrameVirtualRegs(llvm::MachineFunction&, llvm::RegScavenger&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2a78fd3)
#13 0x0000000002a78c42 (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2a78c42)
#14 0x000000000241473b llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x241473b)
#15 0x00000000020ace1a llvm::FPPassManager::runOnFunction(llvm::Function&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x20ace1a)
#16 0x00000000020acc4f llvm::FPPassManager::runOnModule(llvm::Module&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x20acc4f)
#17 0x00000000024a404e (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x24a404e)
#18 0x00000000024a099a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x24a099a)
#19 0x00000000024b264a (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x24b264a)
#20 0x000000000249b400 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream> >) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x249b400)
#21 0x000000000249aa3d (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x249aa3d)
#22 0x00000000022edb39 clang::ParseAST(clang::Sema&, bool, bool) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x22edb39)
#23 0x000000000291805d clang::FrontendAction::Execute() (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x291805d)
#24 0x00000000029176f1 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x29176f1)
#25 0x000000000290e0de clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x290e0de)
#26 0x000000000290b581 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x290b581)
#27 0x0000000002c8f695 (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2c8f695)
#28 0x0000000004774642 clang::driver::CC1Command::setEnvironment(llvm::ArrayRef<char const*>) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x4774642)
#29 0x0000000002d30b3e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2d30b3e)
#30 0x0000000002d30a78 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, bool*) const (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2d30a78)
#31 0x000000000257a576 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x257a576)
#32 0x0000000002579670 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) const (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2579670)
#33 0x0000000002579440 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2579440)
#34 0x0000000002573a1a main (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x2573a1a)
#35 0x00007f455a5431a2 __libc_start_main (/lib64/libc.so.6+0x281a2)
#36 0x00000000046f7641 _start (/tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+++0x46f7641)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android (6875598, based on r399163b) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
Target: armv7a-unknown-linux-android30
Thread model: posix
InstalledDir: /tmp/android-ndk-r22-beta1/toolchains/llvm/prebuilt/linux-x86_64/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/SkSLByteCode-966658.cpp
clang++: note: diagnostic msg: /tmp/SkSLByteCode-966658.sh
clang++: note: diagnostic msg: 

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

SkSLByteCode-966658.zip

Trigger appears to be the combination of '-mfpu=neon' -mthumb -fomit-frame-pointer -Oz.

Environment Details

Not all of these will be relevant to every bug, but please provide as much
information as you can.

  • NDK Version: r22-beta1 (but the crash is present in earlier/stable releases also)
  • Build system: custom/cmdline invocation
  • Host OS: Linux (Fedora 33, also Ubuntu)
  • NDK API level: tried 30,23,19
@DanAlbert
Copy link
Member

@fmalita usually a good local work around for these sorts of issues is manually disabling optimization on the function causing the crash with https://clang.llvm.org/docs/AttributeReference.html#optnone.

Rates as medium according to https://github.com/android/ndk/wiki/NDK-Release-Process, so will want to cherry-pick the fix for r21 and r22 when we get it.

@DanAlbert
Copy link
Member

@stephenhines @pirama-arumuga-nainar the duped bug links to http://b/172773885 as well.

@pirama-arumuga-nainar
Copy link
Collaborator

Reproduces in my upstream LLVM tree (sync-ed to c43f8c772886ff from Nov 10).

@pirama-arumuga-nainar
Copy link
Collaborator

pirama-arumuga-nainar commented Nov 19, 2020

Here's output + clang invocation reduced with creduce.

SkSLByteCode-966658.zip

@pirama-arumuga-nainar
Copy link
Collaborator

Filed https://bugs.llvm.org/show_bug.cgi?id=48232 in LLVM issue tracker.

@leleliu008

This comment has been minimized.

@DanAlbert

This comment has been minimized.

@stephenhines
Copy link
Collaborator

https://android-review.googlesource.com/c/toolchain/llvm_android/+/1573931 is where this will be fixed for r23.

@stephenhines
Copy link
Collaborator

https://android-review.googlesource.com/c/toolchain/llvm_android/+/1585412 fixes it for r22b (the r399163b1 toolchain).

grendello added a commit to grendello/xamarin-android that referenced this issue Mar 25, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r22#r22b
Context: android/ndk#1427

Upstream changes:

  * [Issue 1377][0]: Fix Clang backend crash in register scavenging.
  * [Issue 1388][1]: Fixed LLVM's incorrect conversion to list files for long command lines on Windows.
  * [Issue 1391][2]: Fixed missing symbols from libz.a.
  * [Issue 1427][3]: Fixed Clang auto-detection for CMake 3.19 and older for Windows.

Fix for issue 1427 above allows us to remove the older Android cmake
toolchain file we've been using to work around the bug on Windows
platforms.

[0]: android/ndk#1377
[1]: android/ndk#1388
[2]: android/ndk#1391
[3]: android/ndk#1427
jonpryor pushed a commit to dotnet/android that referenced this issue Mar 26, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r22#r22b
Context: android/ndk#1427

Upstream changes:

  * [Issue 1377][0]: Fix Clang backend crash in register scavenging.
  * [Issue 1388][1]: Fixed LLVM's incorrect conversion to list files
    for long command lines on Windows.
  * [Issue 1391][2]: Fixed missing symbols from `libz.a`.
  * [Issue 1427][3]: Fixed Clang auto-detection for CMake 3.19 and
    older for Windows.

The fix for issue 1427 above allows us to remove the older Android
cmake toolchain file we've been using (accc846) to work around the
bug on Windows platforms.

[0]: android/ndk#1377
[1]: android/ndk#1388
[2]: android/ndk#1391
[3]: android/ndk#1427
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants