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

wasm32-unknown-unknown stuck in infinite loop when compiling fluent-bundle at opt-level=3 #91011

Open
SOF3 opened this issue Nov 18, 2021 · 3 comments
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SOF3
Copy link
Contributor

SOF3 commented Nov 18, 2021

I failed to reproduce a minimum reproducible example for this bug, but the full steps to reproduce my scenario is found here: https://github.com/traffloat/traffloat/runs/4251506793

(Put simply: clone the repo, cd client, run cargo build --target wasm32-unknown-unknown )

Observation: when cargo compiles up to the fluemt-bundle crate, rustc keeps running for a few minutes on 100% CPU, using more and more RAM until the OOM killer from the OS stops it.

This only happens when I compile without the --releade flag. However, pay attention that I set opt-level=3 in the workspace Cargo.toml.

Furthermore, this only happens in the build stage with --target wasm32-unknown-unknown. This does not happen on x86_64-unknown-linux-gnu.

The issue cannot be reproduced by compiling a dummy crate that only includes that dependency.

Meta

rustc --version --verbose:

$ rustc --version --verbose                                                     rustc 1.58.0-nightly (d914f17ca 2021-11-16)
binary: rustc
commit-hash: d914f17ca71a33a89b2dc3436fca51b1a091559e
commit-date: 2021-11-16
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
Backtrace

error: could not compile `fluent-bundle`                                        
Caused by:
  process didn't exit successfully: `CARGO=/home/sofe/.rustup/toolchains/nightly-2021-11-17-x86_64-unknown-linux-gnu/bin/cargo CARGO_CRATE_NAME=fluent_bundle CARGO_MANIFEST_DIR=/home/sofe/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/fluent-bundle-0.15.2 CARGO_PKG_AUTHORS='Zibi Braniecki <gandalf@mozilla.com>:Staś Małolepszy <stas@mozilla.com>' CARGO_PKG_DESCRIPTION='A localization system designed to unleash the entire expressive power of
  natural language translations.
  ' CARGO_PKG_HOMEPAGE='http://www.projectfluent.org' CARGO_PKG_LICENSE=Apache-2.0/MIT CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=fluent-bundle CARGO_PKG_REPOSITORY='https://github.com/projectfluent/fluent-rs' CARGO_PKG_VERSION=0.15.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=15 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/home/sofe/proj/traffloat/target/debug/deps:/home/sofe/.rustup/toolchains/nightly-2021-11-17-x86_64-unknown-linux-gnu/lib:/home/sofe/.rustup/toolchains/nightly-2021-11-17-x86_64-unknown-linux-gnu/lib' rustc --crate-name fluent_bundle --edition=2018 /home/sofe/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/fluent-bundle-0.15.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on --cfg 'feature="default"' -C metadata=d64013c212ea53c9 -C extra-filename=-d64013c212ea53c9 --out-dir /home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -L dependency=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps -L dependency=/home/sofe/proj/traffloat/target/debug/deps --extern fluent_langneg=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libfluent_langneg-20e6de4d2a5c2f31.rmeta --extern fluent_syntax=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libfluent_syntax-6330210a26c5ec71.rmeta --extern intl_memoizer=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libintl_memoizer-be378e2b3f9d6ab2.rmeta --extern intl_pluralrules=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libintl_pluralrules-d90b40ad54dbd6fe.rmeta --extern rustc_hash=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/librustc_hash-e990337399c22a21.rmeta --extern self_cell=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libself_cell-b546eeb8cbdb720e.rmeta --extern smallvec=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libsmallvec-982c24cfab604cb7.rmeta --extern unic_langid=/home/sofe/proj/traffloat/target/wasm32-unknown-unknown/debug/deps/libunic_langid-a07d0b70489807ae.rmeta --cap-lints warn` (signal: 9, SIGKILL: kill)

@SOF3 SOF3 added the C-bug Category: This is a bug. label Nov 18, 2021
@SOF3 SOF3 changed the title wasm32-unknown-unknown stuck in infinite loop wasm32-unknown-unknown stuck in infinite loop when compiling fluent-bundle Nov 18, 2021
@inquisitivecrystal inquisitivecrystal added I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. I-prioritize Issue: Indicates that prioritization has been requested for this issue. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Nov 19, 2021
@adrian17
Copy link

The issue cannot be reproduced by compiling a dummy crate that only includes that dependency.

Sounds very similar to what I experienced in #89647 , may be same as #89524 too.

@SOF3
Copy link
Contributor Author

SOF3 commented Nov 21, 2021

I have checked that disabling optimizations stops reproducing this issue.

Note that my workspace was configured like this:

[profile.dev]
opt-level = 3

[profile.dev.package]
my-first-package = {opt-level = 0}
my-second-package = {opt-level = 0}
my-other-packages = {opt-level = 0}

By applying the patch

 [profile.dev]
-opt-level = 3
+opt-level = 0

the issue is no longer reproduced.

Furthermore, this bug is also avoided by disabling optimizations for fluent-bundle only:

[profile.dev.package]
+fluent-bundle = {opt-level = 0}

The issue also doesn't occur in opt-level = 2. This seems to imply that the optimizations from level 2 to level 3 are causing the bug.

Strange thing is that the issue is not reproduced when I compile the whole project in release mode. Maybe something to do with the inconsistency of debug_assertions vs opt-level?

Note also that I have LTO enabled in release mode where this bug is not reproduced, but that seems unlikely to be relevant.

SOF3 added a commit to traffloat/traffloat that referenced this issue Nov 21, 2021
rust-lang/rust#91011 will occur if the default opt-level=3 is used.
@apiraino
Copy link
Contributor

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 23, 2021
@SOF3 SOF3 changed the title wasm32-unknown-unknown stuck in infinite loop when compiling fluent-bundle wasm32-unknown-unknown stuck in infinite loop when compiling fluent-bundle at opt-level=3 Dec 11, 2022
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. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. O-wasm Target: WASM (WebAssembly), http://webassembly.org/ 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

5 participants