Skip to content

Broadcast at monitor exit, so a thread entering always wakes - #20

Merged
atgreen merged 1 commit into
atgreen:masterfrom
burinc:fix/monitor-exit-broadcast
Oct 18, 2026
Merged

atgreen merged 1 commit into
atgreen:masterfrom
burinc:fix/monitor-exit-broadcast

Conversation

@burinc

@burinc burinc commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

monitor-exit frees the monitor and wakes one thread with bordeaux-threads:condition-notify, on the monitor's condition variable, which threads blocked entering share with threads in Object.wait(). When the wakeup lands on a wait(), that thread sees it is still in the wait set and goes back to sleep, and a thread entering stays asleep at the door of a free monitor until something else wakes it.

This makes it sb-thread:condition-broadcast, which notify() and notifyAll() already use on the same condition variable. Threads entering re-check the owner and all but one go back to waiting; threads in wait() re-check their wait-set membership, as they already must.

Checks: the new aaa/monitorwake.java, a thread entering while another holds the monitor for 300 ms and a third sits in wait(5000), entered after about 5190 ms on master three runs out of three, when the expiring wait exited the monitor and notified again, and after about 190 ms with the fix. make check-regression passes on macOS arm64, 504 core passes, no losses against the baseline.

Re-verified against master at 4498cd2 (2026-10-19).

@atgreen
atgreen merged commit d06ad61 into atgreen:master Oct 18, 2026
0 of 2 checks passed
@burinc

burinc commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

The red build on master after this merge comes from ocicl install, not the change. The macOS job stops while downloading checkl from ghcr.io with Connection reset by peer, before any OpenLDK source compiles, and the ubuntu job was cancelled by fail-fast rather than failing.

I replayed the same tree on my fork. Unchanged, it failed the same way, on parse-number this time after several reset retries: https://github.com/burinc/openldk/actions/runs/39256929013

With the job-level env you suggested in ocicl/ocicl#210 (OCICL_HTTP_RETRIES: "6", OCICL_DOWNLOAD_CONCURRENCY: "2") and fail-fast: false, both jobs pass, regression gates included: https://github.com/burinc/openldk/actions/runs/39257941514. Those five lines in .github/workflows/test.yml are the only difference from d06ad61 in that run.

So a re-run of the master job should go green. I can open a PR with the env lines if you want them until the ocicl fix ships.

@atgreen

atgreen commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Thanks — I cherry-picked 6c98d86 from your ci-replay-d06ad61 branch straight onto master as 5fa8f02 (your authorship kept, the two empty replay commits left out), so there's no need to open a PR for it. Master is green again on both ubuntu-latest and macos-latest: https://github.com/atgreen/openldk/actions/runs/39274299240

burinc pushed a commit to burinc/openldk that referenced this pull request Oct 20, 2026
wait(J) and wait0(J) give up the monitor and wake one thread on its
condition variable, which threads entering share with threads in wait().
When that wakeup lands on another wait(), the thread entering sleeps at
the door of a free monitor until the other wait times out.  This is the
same lost wakeup PR atgreen#20 fixed in monitor-exit; broadcast here too.

The new aaa/waitwake.java enters after ~5000 ms without the fix (3/3)
and immediately with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants