cargo: `cargo build` intermittently fails on darwin platform

Problem

cargo build intermittently fails for a project or its dependencies and subsequent re-builds succeed. For example, bitfield doesn’t have dependencies but this problem is observed for the project itself:

ash@cube ~/git/rust-bitfield % cargo build
   Compiling bitfield v0.13.2 (/Users/ash/git/rust-bitfield)
error: could not compile `bitfield`

Caused by:
  process didn't exit successfully: `rustc --crate-name bitfield src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=c7b624d34760ee7b -C extra-filename=-c7b624d34760ee7b --out-dir /Users/ash/git/rust-bitfield/target/debug/deps -C incremental=/Users/ash/git/rust-bitfield/target/debug/incremental -L dependency=/Users/ash/git/rust-bitfield/target/debug/deps` (signal: 6, SIGABRT: process abort signal)
ash@cube ~/git/rust-bitfield % cargo build
   Compiling bitfield v0.13.2 (/Users/ash/git/rust-bitfield)
    Finished dev [unoptimized + debuginfo] target(s) in 0.18s

Subsequent rebuilds sometimes don’t help and some project continue failing.

Steps

  1. Try to build a cargo project

Possible Solution(s)

No response

Notes

This problem is observed on:

macOs Monterey
Version 12.0.1

Version

cargo 1.55.0
release: 1.55.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I have opened https://github.com/rust-lang/rust/issues/92173 on the rustc side for this issue, as the realloc failure is almost certainly not a cargo issue.

I’m still curious about the discussion above about the descriptor limits. That seems unrelated, but I’d like to better understand if it is something that needs attention.

@akscram and everyone else here, can you say how you installed rust? Was it via the official builds (rustup or manually)? Or was it through a package manager?

I can confirm, raising fd limit helps on my system as well:

 % ulimit -n
256
 % nix run nixpkgs#cargo -- build
   Compiling bitfield v0.13.2 (/Users/yorik/tmp/rust-bitfield)
error: could not compile `bitfield`

Caused by:
  process didn't exit successfully: `rustc --crate-name bitfield src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=c7b624d34760ee7b -C extra-filename=-c7b624d34760ee7b --out-dir /Users/yorik/tmp/rust-bitfield/target/debug/deps -C incremental=/Users/yorik/tmp/rust-bitfield/target/debug/incremental -L dependency=/Users/yorik/tmp/rust-bitfield/target/debug/deps` (signal: 6, SIGABRT: process abort signal)
 % ulimit -n 4096                
 % ulimit -n     
4096
 % nix run nixpkgs#cargo -- build
   Compiling bitfield v0.13.2 (/Users/yorik/tmp/rust-bitfield)
    Finished dev [unoptimized + debuginfo] target(s) in 0.56s