Skip to content

extern crate inside a function scope dependent on that crate causes a stack overflow #87932

Closed
@echeran

Description

@echeran

I've been working on a branch where I've made some refactoring changes and I'm working through cargo check errors/warnings/etc. now. Unexpectedly, one of the errors was from rustc mentioning "overflowed the stack":

Code

To reproduce:

  1. Check out the branch uniset-zerovec-rustc-bug in the repo echeran/icu4x
  2. cd icu4x
  3. Apply the patch listed below (uncomment a single line)
  4. cd components/uniset
  5. cargo check --tests
diff --git a/components/uniset/src/utils.rs b/components/uniset/src/utils.rs
index 80ef039c..aea83a3e 100644
--- a/components/uniset/src/utils.rs
+++ b/components/uniset/src/utils.rs
@@ -7,7 +7,7 @@ use core::{
     ops::{Bound::*, RangeBounds},
 };
 use zerovec::ZeroVec;
-// use zerovec::ule::AsULE;
+use zerovec::ule::AsULE;
 
 /// Returns whether the vector is sorted ascending non inclusive, of even length,
 /// and within the bounds of `0x0 -> 0x10FFFF` inclusive.

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

Error output

thread 'rustc' has overflowed its stack
fatal runtime error: stack overflow
error: could not compile `icu_uniset`

Caused by:
  process didn't exit successfully: `rustc --crate-name icu_uniset --edition=2018 components/uniset/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="provider_serde"' --cfg 'feature="serde"' -C metadata=fa6668d369c85c18 -C extra-filename=-fa6668d369c85c18 --out-dir /home/elango/oss/icu4x/target/debug/deps -C incremental=/home/elango/oss/icu4x/target/debug/incremental -L dependency=/home/elango/oss/icu4x/target/debug/deps --extern displaydoc=/home/elango/oss/icu4x/target/debug/deps/libdisplaydoc-bda10fc3c30caa52.so --extern icu_provider=/home/elango/oss/icu4x/target/debug/deps/libicu_provider-d5ba73d690619b0a.rmeta --extern litemap=/home/elango/oss/icu4x/target/debug/deps/liblitemap-d68fb71c1eeb4154.rmeta --extern serde=/home/elango/oss/icu4x/target/debug/deps/libserde-6382802c6babb864.rmeta --extern tinystr=/home/elango/oss/icu4x/target/debug/deps/libtinystr-e89d95cd91a15395.rmeta --extern zerovec=/home/elango/oss/icu4x/target/debug/deps/libzerovec-75743d7b0ecdd6d0.rmeta` (signal: 6, SIGABRT: process abort signal)

Backtrace N/A.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions