Skip to content

"memory allocation of _ bytes failed" when compiling certain crates #68607

@nwn

Description

@nwn

When trying to compile Rocket as a dependency on nightly, the build intermittently fails after making a large allocation, typically of about 34GB.

In the process, the system memory usage quickly reaches capacity and then the error occurs after a few seconds.

Possibly related: rust-lang/cargo#7840

Reproduction

Run cargo.exe new rocket_test.
Add rocket = "0.4" as a dependency to Cargo.toml.
Run cargo.exe build on nightly.

Meta

System
Windows 10
16GB RAM

Rustc version

$ rustc.exe --version --verbose
rustc 1.42.0-nightly (8a79d08fa 2020-01-27)
binary: rustc
commit-hash: 8a79d08fa57e1c257d647c9848e35defcb379c07
commit-date: 2020-01-27
host: x86_64-pc-windows-msvc
release: 1.42.0-nightly
LLVM version: 9.0

Cargo output

$ cargo.exe --verbose build
       Fresh unicode-xid v0.1.0
       Fresh version_check v0.1.5
       Fresh smallvec v1.1.0
       Fresh matches v0.1.8
       Fresh yansi v0.4.0
       Fresh cc v1.0.50
       Fresh cfg-if v0.1.10
       Fresh percent-encoding v1.0.1
       Fresh version_check v0.9.1
       Fresh autocfg v1.0.0
       Fresh safemem v0.3.3
       Fresh yansi v0.5.0
       Fresh untrusted v0.6.2
       Fresh language-tags v0.2.2
       Fresh typeable v0.1.2
       Fresh traitobject v0.1.0
       Fresh state v0.4.1
       Fresh unicode-normalization v0.1.12
       Fresh unicode-bidi v0.3.4
   Compiling ring v0.13.5
     Running `rustc --crate-name build_script_build C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.13.5\build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg "feature=\"default\"" --cf
g "feature=\"dev_urandom_fallback\"" --cfg "feature=\"use_heap\"" -C metadata=1a15ad6c82b60c04 -C extra-filename=-1a15ad6c82b60c04 --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\build\ring-1a15ad6c82b60c04 -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\dep
s --extern cc=C:\Users\Nathan\Desktop\rocket\target\debug\deps\libcc-946cf986cc7db055.rlib --cap-lints allow`
   Compiling rocket_codegen v0.4.2
   Compiling rocket v0.4.2
   Compiling proc-macro2 v0.4.30
   Compiling libc v0.2.66
   Compiling byteorder v1.3.2
     Running `rustc --crate-name build_script_build C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\rocket_codegen-0.4.2\build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=284f14c65bf
013fe -C extra-filename=-284f14c65bf013fe --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\build\rocket_codegen-284f14c65bf013fe -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\deps --extern version_check=C:\Users\Nathan\Desktop\rocket\target\debug\deps\libve
rsion_check-8db3cc685504e6bd.rlib --extern yansi=C:\Users\Nathan\Desktop\rocket\target\debug\deps\libyansi-6a6e593e43fda685.rlib --cap-lints allow`
     Running `rustc --crate-name build_script_build C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\rocket-0.4.2\build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 --cfg "feature=\"default\"" --c
fg "feature=\"private-cookies\"" -C metadata=f3930abe81925812 -C extra-filename=-f3930abe81925812 --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\build\rocket-f3930abe81925812 -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\deps --extern version_check=C:\Use
rs\Nathan\Desktop\rocket\target\debug\deps\libversion_check-8db3cc685504e6bd.rlib --extern yansi=C:\Users\Nathan\Desktop\rocket\target\debug\deps\libyansi-6a6e593e43fda685.rlib --cap-lints allow`
     Running `rustc --crate-name proc_macro2 C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\proc-macro2-0.4.30\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg "feat
ure=\"default\"" --cfg "feature=\"nightly\"" --cfg "feature=\"proc-macro\"" -C metadata=c0ae366126deddd3 -C extra-filename=-c0ae366126deddd3 --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\deps -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\deps --extern un
icode_xid=C:\Users\Nathan\Desktop\rocket\target\debug\deps\libunicode_xid-8104dae258f2c7fd.rmeta --cap-lints allow --cfg u128 --cfg use_proc_macro --cfg wrap_proc_macro --cfg proc_macro_span`
     Running `rustc --crate-name libc C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\libc-0.2.66\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg "feature=\"default\
"" --cfg "feature=\"std\"" -C metadata=99fc6d3d0ed157f9 -C extra-filename=-99fc6d3d0ed157f9 --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\deps -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\deps --cap-lints allow --cfg freebsd11 --cfg libc_priv_mod_use --
cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_core_cvoid --cfg libc_packedN`
   Compiling winapi v0.3.8
     Running `rustc --crate-name byteorder C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\byteorder-1.3.2\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg "feature=\
"default\"" --cfg "feature=\"std\"" -C metadata=8e0e2ef74f6e6b59 -C extra-filename=-8e0e2ef74f6e6b59 --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\deps -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\deps --cap-lints allow --cfg byteorder_i128`
     Running `rustc --crate-name winapi C:\Users\Nathan\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-0.3.8\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg "feature=\"conso
leapi\"" --cfg "feature=\"minwinbase\"" --cfg "feature=\"minwindef\"" --cfg "feature=\"ntdef\"" --cfg "feature=\"processenv\"" --cfg "feature=\"profileapi\"" --cfg "feature=\"std\"" --cfg "feature=\"sysinfoapi\"" --cfg "feature=\"timezoneapi\"" --cfg "feature=\"winbase\"" -
C metadata=219eb773078db546 -C extra-filename=-219eb773078db546 --out-dir C:\Users\Nathan\Desktop\rocket\target\debug\deps -L dependency=C:\Users\Nathan\Desktop\rocket\target\debug\deps --cap-lints allow --cfg "feature=\"wincontypes\"" --cfg "feature=\"excpt\"" --cfg "featu
re=\"cfgmgr32\"" --cfg "feature=\"wincon\"" --cfg "feature=\"basetsd\"" --cfg "feature=\"devpropdef\"" --cfg "feature=\"wingdi\"" --cfg "feature=\"ktmtypes\"" --cfg "feature=\"vcruntime\"" --cfg "feature=\"cfg\"" --cfg "feature=\"winnt\"" --cfg "feature=\"libloaderapi\"" --
cfg "feature=\"guiddef\"" --cfg "feature=\"winreg\"" --cfg "feature=\"vadefs\"" --cfg "feature=\"windef\"" --cfg "feature=\"processthreadsapi\"" --cfg "feature=\"ntstatus\"" --cfg "feature=\"fileapi\"" -l dylib=advapi32 -l dylib=cfgmgr32 -l dylib=gdi32 -l dylib=kernel32 -l
dylib=msimg32 -l dylib=opengl32 -l dylib=user32 -l dylib=winspool`
   Compiling idna v0.1.5
memory allocation of 36641439744 bytes failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions