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

rustc 1.25.0 panics with "Cannot allocate memory" while building Firefox 59 for Manjaro Linux i686 within Docker build container #49853

Closed
jonathonf opened this issue Apr 10, 2018 · 6 comments
Labels
C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jonathonf
Copy link

jonathonf commented Apr 10, 2018

Summary

While trying to build Firefox 59.0.2 for i686 under a Manjaro Linux (Arch-like) Docker-based build container, rustc panics with "Cannot allocate memory" while compiling the gkrust crate.

I'm reporting because the backtrace asked me to. :)

Details

On first look this would appear to be rustc trying to allocate more than ~3GB RAM during the LTO step as seen https://bugzilla.mozilla.org/show_bug.cgi?id=1417268#c13, and a similar thing last occurred with rustc 1.22 (https://bbs.archlinux32.org/viewtopic.php?id=643).

Monitoring RAM usage during the failing compilation step appears to show it remaining fairly constant at ~1.3GB RES for a "long" period (~50% time before failure), jumping to ~1.5GB RES, then jumping again to 1.7GB and 2.0GB (~80% TBF), before finally (~95% TBF) rapidly increasing in ~100MB steps and panicking somewhere around ~3GB RES.

I am able to successfully build 64-bit Firefox 59.0.2, as well as both 32- and 64-bit Firefox ESR 52.7.3 with the same build container setup, so it looks to be something specific between i686 rustc and FF 59's use of the gkrust crate.

I have not set any resource limits for Docker.

Steps which might reproduce

git clone https://github.com/jonathonf/manjaro-32-build.git
mkdir firefox && cd $_
curl -L -f "https://git.archlinux.org/svntogit/packages.git/snapshot/packages/firefox.tar.gz" -o - | bsdtar --strip-components 3 --include="*/firefox/trunk/" -xvf -
../manjaro-32-build/run.sh

Failing command with flags

/usr/bin/rustc --crate-name gkrust lib.rs --color always --crate-type staticlib --emit=dep-info,link -C opt-level=2 -C panic=abort -C lto --cfg feature="bindgen" --cfg feature="cubeb-remoting" --cfg feature="cubeb_pulse_rust" --cfg feature="gkrust-shared" --cfg feature="no-static-ideograph-encoder-tables" --cfg feature="servo" --cfg feature="simd-accel" -C metadata=651646389c08113e -C extra-filename=-651646389c08113e --out-dir /build/src/mozilla-unified/obj-i686-pc-linux-gnu/toolkit/library/i686-unknown-linux-gnu/release/deps --target i686-unknown-linux-gnu -C linker=/build/src/mozilla-unified/build/cargo-linker -L dependency=/build/src/mozilla-unified/obj-i686-pc-linux-gnu/toolkit/library/i686-unknown-linux-gnu/release/deps -L dependency=/build/src/mozilla-unified/obj-i686-pc-linux-gnu/toolkit/library/release/deps --extern gkrust_shared=/build/src/mozilla-unified/obj-i686-pc-linux-gnu/toolkit/library/i686-unknown-linux-gnu/release/deps/libgkrust_shared-f2bb0c738944c0f6.rlib -C opt-level=2 -C debuginfo=2

Backtrace

 8:40.67    Compiling gkrust v0.1.0 (file:///build/src/mozilla-unified/toolkit/library/rust)
35:17.52 thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: StringError("Cannot allocate memory") }', libcore/result.rs:945:5
35:17.53 stack backtrace:
35:17.71    0: 0xf747766a - rust_metadata_std_ae049937c58eac2695c432bfa6d5d39f
35:17.71    1: 0xf746f0fb - rust_metadata_std_ae049937c58eac2695c432bfa6d5d39f
35:17.71    2: 0xf7474224 - rust_metadata_std_ae049937c58eac2695c432bfa6d5d39f
35:17.71    3: 0xf7473f4f - rust_metadata_std_ae049937c58eac2695c432bfa6d5d39f
35:17.71    4: 0xf74746a1 - std::panicking::rust_panic_with_hook::hb8beb8efb6b91903
35:17.71    5: 0xf7474515 - rust_metadata_std_ae049937c58eac2695c432bfa6d5d39f
35:17.71    6: 0xf7474496 - std::panicking::begin_panic_fmt::he4dfe7a67e7c0076
35:17.71    7: 0xf74743fb - rust_begin_unwind
35:17.71    8: 0xf74e226e - core::panicking::panic_fmt::he2c3b98e9730a002
35:17.71    9: 0xf04c7497 - <unknown>
35:17.71   10: 0xf04f5667 - <unknown>
35:17.71   11: 0xf04f4320 - <unknown>
35:17.71   12: 0xf0593809 - <unknown>
35:17.71   13: 0xf05912b1 - <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::join_trans_and_link::hd108c8a9e5d89c4d
35:17.71   14: 0xf762d843 - rustc_driver::driver::compile_input::hd9c20dd67b35c276
35:17.71   15: 0xf764a9b5 - rustc_driver::run_compiler::h2b965134b6c46ea8
35:17.71   16: 0xf756d933 - rust_metadata_rustc_driver_9af17ad1a24b9c2356fb6a6c6e5db9d5
35:17.71   17: 0xf748bdd2 - __rust_maybe_catch_panic
35:17.71   18: 0xf75a7b93 - <unknown>
35:17.71   19: 0xf7482bfa - rust_metadata_std_ae049937c58eac2695c432bfa6d5d39f
35:17.71   20: 0xf5854e55 - start_thread
35:17.71   21: 0xf73366b5 - __GI___clone
35:17.71   22:        0x0 - <unknown>
35:17.75 
35:17.75 error: internal compiler error: unexpected panic
35:17.75 
35:17.75 note: the compiler unexpectedly panicked. this is a bug.
35:17.75 
35:17.75 note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
35:17.75 
35:17.75 note: rustc 1.25.0 running on i686-unknown-linux-gnu
35:17.75 
35:17.94 error: Could not compile `gkrust`.
35:17.94 
35:17.94 To learn more, run the command again with --verbose.
35:17.94 make[4]: *** [/build/src/mozilla-unified/config/rules.mk:972: force-cargo-library-build] Error 101
35:17.94 make[3]: *** [/build/src/mozilla-unified/config/recurse.mk:73: toolkit/library/rust/target] Error 2
35:17.94 make[2]: *** [/build/src/mozilla-unified/config/recurse.mk:33: compile] Error 2
35:17.94 make[1]: *** [/build/src/mozilla-unified/config/rules.mk:434: default] Error 2
35:17.94 make: *** [client.mk:168: build] Error 2
35:17.97 0 compiler warnings present.
35:18.04 Failed to parse ccache stats output: stats zero time                     Thu Apr  5 15:52:33 2018
35:18.04 Notification center failed: Install notify-send (usually part of the libnotify package) to get a notification when the build finishes.

rustc --version --verbose

rustc 1.25.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: i686-unknown-linux-gnu
release: 1.25.0
LLVM version: 6.0

Packaging files

rustc: https://www.archlinux.org/packages/community/x86_64/rust/
firefox: https://www.archlinux.org/packages/extra/x86_64/firefox/

@cuviper
Copy link
Member

cuviper commented Apr 11, 2018

I saw similar issues on armv7 in #45854, first for rustc itself and later reported with Firefox. In Fedora, I've now disabled rust debuginfo on all 32-bit platforms as a workaround. :-/

@jonathonf
Copy link
Author

export RUSTFLAGS="-Cdebuginfo=0" works wonders. Build succeeded and it cut compilation time!

@pietroalbini pietroalbini added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. C-bug Category: This is a bug. labels Apr 11, 2018
@nikomatsakis
Copy link
Contributor

triage: P-medium

Discussed in the @rust-lang/compiler meeting -- is it possible to do a run with massif (in 64-bit, presumably), to try and see where the memory usage has gone? In general, we feel like it's probably best to just try to reduce memory usage generally, but if there's a specific change it might be good to know.

@jonathonf
Copy link
Author

It's looking like getting this specific step to run under valgrind might be tricky; I'll keep looking though. Alternatively, I'll see whether I can replicate something similar with a more minimal use of the gkrust crate.

@steveklabnik
Copy link
Member

Visiting for triage. A lot has changed, are you still seeing this? any chance of a smaller reproduction?

@Noratrieb Noratrieb added O-x86_64 Target: x86-64 processors (like x86_64-*) O-x86_32 Target: x86 processors, 32 bit (like i686-*) and removed O-x86-all labels Oct 25, 2023
@Mark-Simulacrum
Copy link
Member

Going to go ahead and close since we don't have a minimal reproduction and it's been years - including changes to gkrust and such.

@Mark-Simulacrum Mark-Simulacrum closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) 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

8 participants