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

Opaque error error message if LLVM OOMs during full LTO #85598

Open
matklad opened this issue May 23, 2021 · 2 comments
Open

Opaque error error message if LLVM OOMs during full LTO #85598

matklad opened this issue May 23, 2021 · 2 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matklad
Copy link
Member

matklad commented May 23, 2021

Starting today, I am seeing the following error in rust-analyzer's CI

   Compiling ide_ssr v0.0.0 (D:\a\rust-analyzer\rust-analyzer\crates\ide_ssr)
   Compiling ide v0.0.0 (D:\a\rust-analyzer\rust-analyzer\crates\ide)
fatal runtime error: Rust cannot catch foreign exceptions
error: could not compile `rust-analyzer`

Caused by:
  process didn't exit successfully: `rustc --crate-name rust_analyzer --edition=2018 crates\rust-analyzer\src/bin/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C debuginfo=1 -C metadata=79e139aff8fa11a3 --out-dir D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps --target x86_64-pc-windows-msvc -C linker=rust-lld -L dependency=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps -L dependency=D:\a\rust-analyzer\rust-analyzer\target\release\deps --extern always_assert=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libalways_assert-a5c3950cbac605c2.rlib --extern anyhow=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libanyhow-b92146a0e6d6413a.rlib --extern cfg=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libcfg-3451d2c1a2e1dd21.rlib --extern crossbeam_channel=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libcrossbeam_channel-8dc7041ff99977ca.rlib --extern dissimilar=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libdissimilar-a85bc727a6ef040f.rlib --extern env_logger=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libenv_logger-0c1b28edc895da2b.rlib --extern flycheck=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libflycheck-5a3d33ebf8982c91.rlib --extern hir=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libhir-f1c482a9f52ec024.rlib --extern hir_def=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libhir_def-84f9901156f3c37e.rlib --extern hir_ty=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libhir_ty-a9ff862504d19d8d.rlib --extern ide=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libide-aca7a6f5717b60fb.rlib --extern ide_db=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libide_db-30818be798bb4bd5.rlib --extern ide_ssr=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libide_ssr-25d0dd581c0a1f21.rlib --extern itertools=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libitertools-795925f20865e421.rlib --extern jod_thread=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libjod_thread-7b553ff844830aa9.rlib --extern log=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\liblog-d97217edfa7fa3e7.rlib --extern lsp_server=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\liblsp_server-1e7f9bab880d71c8.rlib --extern lsp_types=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\liblsp_types-55078c6e33798392.rlib --extern oorandom=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\liboorandom-fdca57d9670229c1.rlib --extern parking_lot=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libparking_lot-7574759f69a57d6d.rlib --extern proc_macro_srv=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libproc_macro_srv-14eb3c78110c3882.rlib --extern profile=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libprofile-4da50626cb505dfd.rlib --extern project_model=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libproject_model-54a1bf11492f68c6.rlib --extern rayon=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\librayon-0a74d6af60e18fd2.rlib --extern rust_analyzer=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\librust_analyzer-2fedc7074222fbbe.rlib --extern rustc_hash=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\librustc_hash-fd535a62a1631d92.rlib --extern serde=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libserde-aa69b9bf35e75485.rlib --extern serde_json=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libserde_json-d9c58ca21bdb469a.rlib --extern serde_path_to_error=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libserde_path_to_error-4c50a4fa3dc519a6.rlib --extern stdx=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libstdx-f1ad487878f200cc.rlib --extern syntax=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libsyntax-f7fcb85a088de37a.rlib --extern text_edit=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libtext_edit-b086ec402917223c.rlib --extern threadpool=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libthreadpool-88302915b8bc103a.rlib --extern toolchain=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libtoolchain-4dec8cd4ff032434.rlib --extern tracing=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libtracing-c63fa0ca38f03367.rlib --extern tracing_subscriber=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libtracing_subscriber-a3129190deedb9fe.rlib --extern tracing_tree=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libtracing_tree-700f7dfac6fdc792.rlib --extern vfs=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libvfs-0da9b6babb9c702b.rlib --extern vfs_notify=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libvfs_notify-09fa85939f13d34c.rlib --extern winapi=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libwinapi-a329bfbc416edc71.rlib --extern xflags=D:\a\rust-analyzer\rust-analyzer\target\x86_64-pc-windows-msvc\release\deps\libxflags-3011d41fb4019847.rlib -D warnings -W unreachable-pub` 
(exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
Error: command `cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target x86_64-pc-windows-msvc --release` failed, exit code: 101
error: process didn't exit successfully: `target\debug\xtask.exe dist` (exit code: 1)
Error: Process completed with exit code 1.

This happens on windows builders, when compiling with --target x86_64-pc-windows-msvc or --target aarch64-pc-windows-msvc. The step which fails is compilation of the final binary crate. The binary is complied in --release mode with lto=true. I think the failure appeared after I added debug=1 as well.

So my theory is that maybe this is just some OOM in the linker, and not a problem with rustc per se? The error message is rather unhelpful though.

The relevant CI run: https://github.com/rust-analyzer/rust-analyzer/runs/2649419225?check_suite_focus=true#step:5:330

@matklad matklad added the C-bug Category: This is a bug. label May 23, 2021
matklad added a commit to matklad/rust-analyzer that referenced this issue May 23, 2021
@jonas-schievink jonas-schievink added I-prioritize Issue: Indicates that prioritization has been requested for this issue. O-windows-msvc Toolchain: MSVC, Operating system: Windows labels May 23, 2021
@ehuss
Copy link
Contributor

ehuss commented May 23, 2021

I confirmed that rustc prints Rust cannot catch foreign exceptions when LLVM runs out of memory. Presumably it is raising bad_alloc, but AFAIK rust cannot catch C++ exceptions. I'm not sure if it could be caught on the C++ side, or if there is some LLVM build option to change the oom behavior.

rust-analyzer needs about 5 to 6 GB to build with LTO. I think GitHub Actions systems have 7GB of RAM, so it may be getting close to that limit. I might suggest using 'thin' LTO which should use substantially less memory.

@matklad matklad changed the title Rustc fails to compile rust-analyzer on widows, failing with STATUS_STACK_BUFFER_OVERRUN Opaque error error message if LLVM OOMs during full LTO May 24, 2021
matklad added a commit to matklad/rust-analyzer that referenced this issue May 24, 2021
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 25, 2021
@hameerabbasi
Copy link
Contributor

Assigning P-high based on WG-prioritization discussion on Zulip and removing I-prioritize.

@rustbot modify labels -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 26, 2021
@apiraino apiraino added P-medium Medium priority and removed P-high High priority labels May 27, 2021
@workingjubilee workingjubilee added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants