rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.86k stars 2.43k forks source link

error: failed to wait on curl `Multi` #11435

Open mrusme opened 2 years ago

mrusme commented 2 years ago

When trying to build a project on OpenBSD 7.2 (-current) I'm running into the following error:

$ cargo build --release --verbose
error: failed to wait on curl `Multi`

Caused by:
  Unrecoverable error in select/poll

I tracked down the source of this error:

https://github.com/rust-lang/cargo/blob/a2ea66bea6fe8156444144e98911d073d56c2c0c/src/cargo/core/package.rs#L1014

However, I do not understand why this is happening. I've also run the command with ktrace and skimmed over the attached ktrace.out using kdump -f ktrace.out | less, however I can't see an obvious issue in there either.

I'd appreciate hints!

$ cargo --version
cargo 1.65.0
$ rustc --version
rustc 1.65.0

ktrace.out.gz

mrusme commented 2 years ago

Something that might be worth pointing out, however I can't tell whether that has something to do with the error:

 66655 cargo    CALL  poll(0x7f7ffffdaab0,2,INFTIM)
 66655 cargo    STRU  struct pollfd [2] { fd=4, events=0x1<POLLIN>, revents=0<> } { fd=6, events=0x1<POLLIN>, revents=0x1<POLLIN> }
 66655 cargo    RET   poll 1
 66655 cargo    CALL  read(6,0x4f2c684c60,0x20)
 66655 cargo    GIO   fd 6 read 32 bytes
       "error: `-Csplit-debuginfo=packed"
 66655 cargo    RET   read 32/0x20
 66655 cargo    CALL  read(6,0x4f0526c560,0x20)
 66655 cargo    GIO   fd 6 read 32 bytes
       "` is unstable on this platform

       "
 66655 cargo    RET   read 32/0x20
 66655 cargo    CALL  read(6,0x4f1d8b8840,0x40)
 66655 cargo    RET   read -1 errno 35 Resource temporarily unavailable
 66655 cargo    CALL  poll(0x7f7ffffdaab0,2,INFTIM)
 66655 cargo    STRU  struct pollfd [2] { fd=4, events=0x1<POLLIN>, revents=0x1<POLLIN> } { fd=6, events=0x1<POLLIN>, revents=0<> }
 66655 cargo    RET   poll 1
 66655 cargo    CALL  read(4,0x4ea44e73e0,0x20)
 66655 cargo    GIO   fd 4 read 32 bytes
       "___
        lib___.rlib
        lib___.so
        lib___"
 66655 cargo    RET   read 32/0x20
 66655 cargo    CALL  read(4,0x4f0526cd20,0x20)
 66655 cargo    GIO   fd 4 read 23 bytes
       ".so
        lib___.a
        lib___.so
       "
 66655 cargo    RET   read 23/0x17
 66655 cargo    CALL  read(4,0x4f0526cd37,0x9)
 66655 cargo    RET   read -1 errno 35 Resource temporarily unavailable
 66655 cargo    CALL  poll(0x7f7ffffdaab0,2,INFTIM)
 66655 cargo    STRU  struct pollfd [2] { fd=4, events=0x1<POLLIN>, revents=0<> } { fd=6, events=0x1<POLLIN>, revents=0x1<POLLIN> }
 66655 cargo    RET   poll 1
 66655 cargo    CALL  read(6,0x4f1d8b8840,0x40)
 66655 cargo    GIO   fd 6 read 39 bytes
       "error: aborting due to previous error

       "
 66655 cargo    RET   read 39/0x27
 66655 cargo    CALL  read(6,0x4f1d8b8867,0x19)
 66655 cargo    RET   read -1 errno 35 Resource temporarily unavailable
mrusme commented 2 years ago

Also:

 66655 cargo    CALL  open(0x4ef3089b2a,0x10000<O_RDONLY|O_CLOEXEC>)
 66655 cargo    NAMI  "/usr/local/lib/libcurl.so.26.17"
 66655 cargo    RET   open 3
 66655 cargo    CALL  fstat(3,0x7f7ffffe1070)
 66655 cargo    STRU  struct stat { dev=1027, ino=597100, mode=-rw-r--r-- , nlink=1, uid=0<"root">, gid=7<"bin">, rdev=2429928, atime=1669656999<"Nov 28 17:36:39 2022">.266566436, mtime=1669287004<"Nov 24 10:50:04 2022">, ctime=1669656225<"Nov 28 17:23:45 2022">.806585512, size=760200, blocks=1536, blksize=16384, flags=0x0, gen=0x0 }
 66655 cargo    RET   fstat 0
 66655 cargo    CALL  read(3,0x7f7ffffdf8f0,0x1000)
 66655 cargo    GIO   fd 3 read 4096 bytes

//edit: I've just tried cargo install gitui and it worked flawlessly. It was able to download all dependencies and compile the binary. So it seem like a very specific issue here.

The thing I was trying to build using cargo build --release was lemmy. I first tried cargo install lemmy_server --locked, as suggested in their manual, but I also ran into this issue. Hence I gave git clone and cargo build a go.

ehuss commented 1 year ago

Can you say more about how you installed rust/cargo? Can you provide the output of cargo -Vv? It looks like it may be using the system-installed libcurl. Cargo can be a little finicky if it is not using its vendored libraries. Which version of libcurl do you have installed?

neezer commented 1 year ago

I'm encountering a similar issue, also on OpenBSD 7.2, though I'm trying to install a different package: cargo-binstall (also with helix-editor)

Output of cargo -Vv:

cargo 1.63.0
release: 1.63.0
host: x86_64-unknown-openbsd
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.87.0 (sys:0.4.55+curl-7.83.1 system ssl:LibreSSL/3.6.0)
os: Unknown [unknown bitness]

Cargo was installed by installing rust via pkg_add: I installed the package rust-1.63.0p0.

Think you're right about using the system curl--how do I tell cargo otherwise?

neezer commented 1 year ago

Like @mrusme I'm also seeing this error in the build artifacts:

error: `-Csplit-debuginfo` is unstable on this platform

Seems like this might be related: https://github.com/rust-lang/cargo/pull/11347


Unlike @mrusme attempting cargo install gitui gives me the same error and does not successfully install.

mrusme commented 1 year ago

Can you say more about how you installed rust/cargo?

I tried in multiple ways but the one that imho should have worked was by simply installing pkg_add rust on a -current system.

yamadalex commented 1 year ago
OpenBSD 7.3
---------------------------
cargo 1.68.0
release: 1.68.0
host: x86_64-unknown-openbsd
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 8.2.0 (sys:0.4.59+curl-7.86.0 system ssl:LibreSSL/3.7.2)
os: OpenBSD 7.3.0 [64-bit]
---------------------------
rustc 1.68.0 (2c8cc3432 2023-03-06) (built from a source tarball)
binary: rustc
host: x86_64-unknown-openbsd
release: 1.68.0
LLVM version: 15.0.6
---------------------------
cargo build --manifest-path Cargo.toml --message-format=json-render-diagnostics --release -v --no-default-features --locked
             Downloading crates ...
            error: failed to wait on curl `Multi`

            Caused by:
              Unrecoverable error in select/poll
            error: `cargo build --manifest-path Cargo.toml --message-format=json-render-diagnostics --release -v --no-default-features --locked` failed with code 101
            [end of output]

When I try with "normal" user, ex. "cargo install gitui", this finish with no error.

   Updating crates.io index
  Installing gitui v0.23.0
   Compiling libc v0.2.147
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling pkg-config v0.3.27
   Compiling jobserver v0.1.26
   Compiling cc v1.0.82
   Compiling quote v1.0.32
   Compiling vcpkg v0.2.15
   Compiling log v0.4.19
   Compiling syn v2.0.28
   Compiling memchr v2.5.0
   Compiling bitflags v1.3.2
   Compiling openssl-src v111.27.0+1.1.1v
   Compiling serde v1.0.183
   Compiling crossbeam-utils v0.8.16
   Compiling scopeguard v1.2.0
   Compiling syn v1.0.109
   Compiling openssl-sys v0.9.91
   Compiling libz-sys v1.1.12
   Compiling version_check v0.9.4
   Compiling libssh2-sys v0.3.0
...............

But when I try with "root" (or with doas), shows me this error

    Updating crates.io index
  Installing gitui v0.23.0
error: failed to compile `gitui v0.23.0`, intermediate artifacts can be found at `/tmp/cargo-installRobfe8`

Caused by:
  failed to wait on curl `Multi`

Caused by:
  Unrecoverable error in select/poll
josuah commented 1 year ago

It also appears to not be always reproducible:

$ cargo build
error: failed to wait on curl `Multi`
Caused by:
  Unrecoverable error in select/poll
$ cargo build
  Downloaded opentelemetry-jaeger v0.17.0
  Downloaded futures-core v0.3.28
  Downloaded zstd-sys v2.0.8+zstd.1.5.5
  Downloaded libsqlite3-sys v0.26.0
  Downloaded rand_chacha v0.2.2
  Downloaded librocksdb-sys v0.11.0+8.1.1
 Downloading 190 crates, extracting librocksdb-sys ...

Facts about this system:

$ uname -a
OpenBSD ams1.josuah.net 7.3 GENERIC#1072 amd64
$  cargo --version
cargo 1.68.0
$ pkg_info curl
Information for inst:curl-8.2.0

Comment:
transfer files with FTP, HTTP, HTTPS, etc.

Required by:
git-2.40.0
kamailio-5.5.4p2
mariadb-server-10.9.4v1
rust-1.68.0
transmission-3.00p2

Description:
curl is a command line tool for transferring data with URL syntax,
supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP,
IMAPS, MQTT, POP3, POP3S, RTSP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP.
curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP
form based upload, proxies, cookies, user+password authentication
(Basic, Digest, NTLM, Negotiate, ...), file transfer resume, proxy
tunneling and a busload of other useful tricks.

Maintainer: Christian Weisgerber <naddy@openbsd.org>

WWW: https://curl.se/
$ pkg_info rust
Information for inst:rust-1.68.0

Comment:
compiler for Rust Language

Description:
Rust is a systems programming language that runs blazingly fast, prevents
almost all crashes, and eliminates data races.

Featuring:
- zero-cost abstractions
- move semantics
- guaranteed memory safety
- threads without data races
- trait-based generics
- pattern matching
- type inference
- minimal runtime
- efficient C bindings

Documentation is available online at https://doc.rust-lang.org/
or could be downloaded from
https://static.rust-lang.org/dist/rust-docs-1.68.0-x86_64-unknown-linux-gnu.tar.gz

Maintainer: Sebastien Marie <semarie@online.fr>

WWW: https://www.rust-lang.org/

I might be wise to try the same command a couples of time before thinking about which context it happens, as it might very much be luck when running in one context, and not another.

osc86 commented 1 year ago

same problem here, using openbsd 7.3. funny thing is, it works with the first user created, not with root, not with any other 'normal' user. like its locked to uid 1000 or smth.

renatoaguiar commented 1 year ago

Increasing the number of file descriptors, e.g. ulimit -n 1024, fixed it for me.

mrusme commented 10 months ago

I can confirm that on OpenBSD 7.4 this issue can be avoided by setting ulimit -n 1024, as @renatoaguiar said. Thank you kindly!

Feel free to either leave this issue open, in case you believe that cargo should output a hint about raising the ulimit. Otherwise feel free to close it. Thanks!

weihanglo commented 10 months ago

Thanks for the update!

I wonder if it still happens with the latest Cargo (nightly or 1.75.0). If yes, we may leave this open until we find the root cause of this :)

Sir-Photch commented 8 months ago

This is also happening to me on 7.5-current. It is also the file descriptor limit in my case.

madelinehebert commented 2 months ago

ulimit -n 1024 is still working as a fix with Rust 1.76 on OpenBSD 7.5 under SPARC64