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

Two concurrent cargo rustc calls hang #7200

Closed
sigiesec opened this issue Aug 1, 2019 · 1 comment · Fixed by #7201
Closed

Two concurrent cargo rustc calls hang #7200

sigiesec opened this issue Aug 1, 2019 · 1 comment · Fixed by #7201
Labels
C-bug Category: bug

Comments

@sigiesec
Copy link

sigiesec commented Aug 1, 2019

Problem
Quite often my firefox build gets stuck, I need to break it, restart, and by repeating this eventually does a complete build. I investigated one occurance of such a hang closer, and found there were two cargo processes running, started with cargo rustc --frozen --manifest-path.

The two processes are stuck in different states. The following are the backtraces of both processes:

(gdb) thread apply all bt

Thread 1 (Thread 0x7f90233d79c0 (LWP 26667)):
#0  0x00007f902360e60b in flock () at ../sysdeps/unix/syscall-template.S:78
#1  0x000055c19905aa2e in <std::fs::File as fs2::FileExt>::lock_exclusive ()
#2  0x000055c198ea3add in cargo::util::flock::Filesystem::open::{{closure}} ()
#3  0x000055c198ea415a in cargo::util::flock::acquire ()
#4  0x000055c198ea3934 in cargo::util::flock::Filesystem::open ()
#5  0x000055c198c72d99 in cargo::core::compiler::layout::Layout::at ()
#6  0x000055c198c72acb in cargo::core::compiler::layout::Layout::new ()
#7  0x000055c198f2a523 in cargo::core::compiler::context::Context::prepare_units ()
#8  0x000055c198f26855 in cargo::core::compiler::context::Context::compile ()
#9  0x000055c198fe275f in cargo::ops::cargo_compile::compile_ws ()
#10 0x000055c198fe1077 in cargo::ops::cargo_compile::compile ()
#11 0x000055c198c0311c in cargo::commands::rustc::exec ()
#12 0x000055c198be507a in cargo::cli::main ()
#13 0x000055c198c0cb1b in cargo::main ()
#14 0x000055c198c24673 in std::rt::lang_start::{{closure}} ()
#15 0x000055c199489dc3 in std::rt::lang_start_internal::{{closure}} () at src/libstd/rt.rs:49
#16 std::panicking::try::do_call () at src/libstd/panicking.rs:293
#17 0x000055c199495aaa in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:85
#18 0x000055c19948a98d in std::panicking::try () at src/libstd/panicking.rs:272
#19 std::panic::catch_unwind () at src/libstd/panic.rs:394
#20 std::rt::lang_start_internal () at src/libstd/rt.rs:48
#21 0x000055c198c0f1a2 in main ()

(gdb) thread apply all bt

Thread 1 (Thread 0x7fde387b29c0 (LWP 26666)):
#0  0x00007fde389ed588 in __GI___poll (fds=0x7ffc20bc5d28, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x000055a13e76cee5 in jobserver::imp::Client::acquire ()
#2  0x000055a13e7706a9 in jobserver::Client::acquire_raw ()
#3  0x000055a13e1bf187 in cargo::util::flock::acquire ()
#4  0x000055a13e1be934 in cargo::util::flock::Filesystem::open ()
#5  0x000055a13df8dd99 in cargo::core::compiler::layout::Layout::at ()
#6  0x000055a13df8dacb in cargo::core::compiler::layout::Layout::new ()
#7  0x000055a13e245523 in cargo::core::compiler::context::Context::prepare_units ()
#8  0x000055a13e241855 in cargo::core::compiler::context::Context::compile ()
#9  0x000055a13e2fd75f in cargo::ops::cargo_compile::compile_ws ()
#10 0x000055a13e2fc077 in cargo::ops::cargo_compile::compile ()
#11 0x000055a13df1e11c in cargo::commands::rustc::exec ()
#12 0x000055a13df0007a in cargo::cli::main ()
#13 0x000055a13df27b1b in cargo::main ()
#14 0x000055a13df3f673 in std::rt::lang_start::{{closure}} ()
#15 0x000055a13e7a4dc3 in std::rt::lang_start_internal::{{closure}} () at src/libstd/rt.rs:49
#16 std::panicking::try::do_call () at src/libstd/panicking.rs:293
#17 0x000055a13e7b0aaa in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:85
#18 0x000055a13e7a598d in std::panicking::try () at src/libstd/panicking.rs:272
#19 std::panic::catch_unwind () at src/libstd/panic.rs:394
#20 std::rt::lang_start_internal () at src/libstd/rt.rs:48
#21 0x000055a13df2a1a2 in main ()

Steps

  1. run ./mach build on mozilla-unified/central

Possible Solution(s)
No idea.

Notes

Output of cargo version:

[osboxes@sigiesec-mozbln mozilla-unified]$ /home/osboxes/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo version
cargo 1.36.0 (c4fcfb725 2019-05-15)

This is running on Fedora 30.

@sigiesec sigiesec added the C-bug Category: bug label Aug 1, 2019
@sigiesec sigiesec changed the title ps ax Two concurrent cargo rustc calls hang Aug 1, 2019
@alexcrichton
Copy link
Member

Thanks for the report and stack traces! This is definitely a bug in Cargo which is basically a deadlock introduced in #6748, so I'll post a PR to revert that soon.

bors added a commit that referenced this issue Aug 2, 2019
Revert "Release a jobserver token while locking a file"

This reverts commit d19b41f.

Discovered in #7200 this is just a straight up recipe for deadlock. One Cargo has a jobserver token and wants a file lock. Another Cargo has the file lock and wants a jobserver token. If we had a way to acquire a jobserver token in a nonblocking fashion we could perhaps solve this, but for now I think it's best to revert to the previous behavior.

Closes #7200
@bors bors closed this as completed in #7201 Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants