Skip to content

Strange deadlock bug on Rust nightly #36294

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bvssvni opened this issue Sep 6, 2016 · 2 comments · Fixed by #36351
Closed

Strange deadlock bug on Rust nightly #36294

bvssvni opened this issue Sep 6, 2016 · 2 comments · Fixed by #36351
Labels
A-concurrency Area: Concurrency regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@bvssvni
Copy link

bvssvni commented Sep 6, 2016

rustc 1.13.0-nightly (91f057de3 2016-09-04)

This runs forever on Rust stable (1.11) but hangs on Rust nightly.

Reduced case:

use std::sync::{Arc, Mutex};
use std::any::Any;

fn main() {
    let mut counter = 0;
    loop {
        let _ = foo();
        counter += 1;
        println!("counter {}", counter); // stops at ~ 495 - 499
    }
}

fn foo() -> Arc<Mutex<Any>> {
    Arc::new(Mutex::new(false)) as Arc<Mutex<Any>>
}
@nagisa
Copy link
Member

nagisa commented Sep 6, 2016

This is more minimised:

use std::sync::{Arc, Mutex};
use std::any::Any;

fn main() {
    loop {
        drop(foo());
    }
}

fn foo() -> Box<Mutex<Any>> {
    Box::new(Mutex::new(0u32)) as Box<Mutex<Any>>
}

This tries to take a futex in a single threaded program for some reason:

futex(0x7f3b9ca02b40, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x7f3b9ca02b40, FUTEX_WAIT_PRIVATE, 2, NULL…

Only fails at optimisation levels 0 and 1, but not 2 or 3. Also doesn’t fail if inner data is () or u64, but will fail with u8, u16, u32.

@eddyb
Copy link
Member

eddyb commented Sep 6, 2016

This looks like it might be #36278.

@brson brson added A-libs A-concurrency Area: Concurrency regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Sep 7, 2016
pnkfelix added a commit to pnkfelix/rust that referenced this issue Sep 8, 2016
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 10, 2016
…eddyb

When sizing DST, don't double-count nested struct prefixes.

When computing size of `struct P<T>(Q<T>)`, don't double-count prefix added by `Q`

Fix rust-lang#36278. Fix rust-lang#36294.
bors added a commit that referenced this issue Sep 10, 2016
When sizing DST, don't double-count nested struct prefixes.

When computing size of `struct P<T>(Q<T>)`, don't double-count prefix added by `Q`

Fix #36278. Fix #36294.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-concurrency Area: Concurrency regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants