Skip to content

Rwlock handles recursive locking attempts poorly on linux (double unlock) #25012

Closed
@talchas

Description

@talchas

On linux pthread_rwlock_rdlock/wrlock return EDEADLK if you attempt to take the other type of lock when you own one. libstd ignores this when debug-assertions are not on, and then will try to unlock twice anyway. This leads to arbitrarily bad behavior (on playpen it happens to hit x86-HLE code and SIGILL):

use std::sync::RwLock;
fn main() {
    let x = RwLock::new("");
    let _w = x.write().unwrap();
    let _r = x.read().unwrap();
}

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