Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/vm/src/vm/thread/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ mod tests {
#[test]
fn unlock_hands_off_to_starved_waiter() {
let m = Arc::new(PyMutex::new());
let (release_waiter, wait_for_release) = std::sync::mpsc::channel::<()>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the required AI-assistance trailer

The commit message explicitly says Codex assisted, but it contains no Assisted-by: AGENT_NAME:MODEL_VERSION trailer. RustPython requires that exact trailer for every AI-assisted contribution, so this commit's metadata must be corrected before integration.

AGENTS.md reference: AGENTS.md:L23-L23

Useful? React with 👍 / 👎.

m.lock();
let waiter = {
let m = m.clone();
std::thread::spawn(move || {
m.lock();
// Keep ownership until the parent has checked the handoff.
let _ = wait_for_release.recv();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep normal acquisition from satisfying the handoff test

If the implementation regresses to a normal (non-TOKEN_HANDED_OFF) wake-up and the unparked waiter is scheduled before the parent reaches lock_fast, the waiter can acquire the now-unlocked mutex normally. This new recv then keeps that ordinary acquisition locked until after the check, so lock_fast returns false and the handoff test passes despite no direct handoff; the test needs to observe the handoff token/state without allowing an ordinary acquisition to satisfy the assertion.

Useful? React with 👍 / 👎.

m.unlock();
})
};
Expand All @@ -285,9 +288,14 @@ mod tests {
// Long past the waiter's fairness deadline.
std::thread::sleep(Duration::from_millis(20));
m.unlock();
// The waiter owns the lock before it has even run again.
assert!(!m.lock_fast());
// Check immediately, without waiting for the waiter to run again.
let acquired = m.lock_fast();
if acquired {
m.unlock();
}
drop(release_waiter);
waiter.join().unwrap();
assert!(!acquired);
assert!(!m.is_locked());
}
}
Loading