-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fatal error: error in backend: Failed to evaluate function length in SEH unwind info #66912
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
fatal error: error in backend: Failed to evaluate function length in SEH unwind info #66912
Comments
cc'ing @mstorsjo |
I can reproduce the error with clang 15 but not with 14, so either it's a regression, or the issue just happened to go unnoticed before. |
I reduced the testcase to the following: void a();
void b() {
for (;;)
a();
} Compiled with the following command: The issue is that there's an alignment inserted in the middle of a function, which makes it impossible for the SEH unwind info generation to measure the size of the function (as it hasn't been laid out yet, so we don't know how large the alignment gap ends up). In this case, the output is:
Here, the I bisected this down to the commit 7d67671:
|
@llvm/issue-subscribers-backend-aarch64
I've encountered a crash of clang from LLVM 17.01 when trying to build openblas 0.3.24 for Windows/aarch64 on a Linux machine. The crash files and full output with stacktrace are attached in [crash.zip](https://github.com/llvm/llvm-project/files/12674259/crash.zip)
The output includes: fatal error: error in backend: Failed to evaluate function length in SEH unwind info #5 0x00005579fe4a4f70 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/tomas/toolchain/clang/toolchain_libs/mxe/usr/x86_64-pc-linux-gnu/bin/clang+0x1c72f70) |
Edit: Though now I realise this landed about a year ago. Maybe they'll have some thoughts anyway. |
This has also been reported as #47432 and #64504. The underlying backend limitation is known, but hard to fix... it requires a complicated rearrangement of the code to delay computing the length of a function until assembler relaxation. (I think there's some discussion of this elsewhere, but I can't seem to find it.) |
See discussion on https://reviews.llvm.org/D61095 |
Indeed... What's the practical way around it to recommend here? Should we avoid enabling loop alignment in the aarch64 backend, when SEH generation is enabled? |
🆙 |
This probably makes sense. (Given the interaction with debug info, it might make sense to just check if the target in Windows.) |
Ok, great, I'll try to make an effort to do that then.
Can you elaborate on what interaction with debug info you're thinking of here, so I can formulate a good comment explaining the code in the end? |
This should fix llvm#66912. When emitting SEH unwind info, we need to be able to calculate the exact length of functions before alignments are fixed. Until that limitation is overcome, just disable all loop alignment on Windows targets.
I've got a potential fix for this in #67894. |
Thanks, it fixes the problem for me - openblas now compiles without crashing (tested in LLVM 17.01, with the patch applied). |
@kalibera were you able to let OpenBLAS build all the kernels when building for Windows on ARM? I had to remove dynamic arch and force it to be Cortext-A53 only like here: https://github.com/msys2/MINGW-packages/pull/11954/files#diff-ff01e0a0f990bc4bae590e2d4bd2ddbfe71c0ede3550881075673905df875b66R80 |
No, I am building like you - https://svn.r-project.org/R-dev-web/trunk/WindowsBuilds/winutf8/ucrt3/toolchain_libs/mxe/src/openblas.mk. With DYNAMIC_ARCH I get "No rule to make target 'dynamic_arm64.obj'" (which is not related to this bug report). |
This should fix #66912. When emitting SEH unwind info, we need to be able to calculate the exact length of functions before alignments are fixed. Until that limitation is overcome, just disable all loop alignment on Windows targets.
Reopening for backporting the fix for the regression. (The issue with loop alignment probably did exist for other |
/cherry-pick 6ae36c0 |
/branch llvm/llvm-project-release-prs/issue66912 |
/pull-request llvm/llvm-project-release-prs#722 |
Just documenting here that with 19.1.6 we can still repro this issue with as little as this code (built with int f(int i) {
int result;
__asm__ (
".align 5 \n"
"add %w0, %w1, #41"
: "=r" (result)
: "r" (i)
:
);
return result;
} |
Yes, that'll probably trigger it. The issue is twofold; if we have things within the function that makes it impossible to calculate the length of it ahead of time, like an The fix above, in #67894 / 6ae36c0, makes sure that we don't generate Perhaps it would be better to file a new separate issue that case where you explicitly do use |
Done. New ticket created at #122707 |
I've encountered a crash of clang from LLVM 17.01 when trying to build openblas 0.3.24 for Windows/aarch64 on a Linux machine. The crash files and full output with stacktrace are attached in crash.zip
The output includes:
fatal error: error in backend: Failed to evaluate function length in SEH unwind info
#5 0x00005579fe4a4f70 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/tomas/toolchain/clang/toolchain_libs/mxe/usr/x86_64-pc-linux-gnu/bin/clang+0x1c72f70)
#8 0x00005579fe2627dd llvm::MCStreamer::emitWinCFIEndProc(llvm::SMLoc) (/home/tomas/toolchain/clang/toolchain_libs/mxe/usr/x86_64-pc-linux-gnu/bin/clang+0x1a307dd)
#11 0x00005579ff1be469 llvm::AsmPrinter::emitFunctionBody() (/home/tomas/toolchain/clang/toolchain_libs/mxe/usr/x86_64-pc-linux-gnu/bin/clang+0x298c469)
#14 0x00005579fdff2eea llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/tomas/toolchain/clang/toolchain_libs/mxe/usr/x86_64-pc-linux-gnu/bin/clang+0x17c0eea)
The text was updated successfully, but these errors were encountered: