Skip to content

Fix Display.sleep() race condition: make wake volatile, move reset before loop#34

Draft
Copilot wants to merge 1 commit intomasterfrom
copilot/analyze-wake-issues-and-mitigations
Draft

Fix Display.sleep() race condition: make wake volatile, move reset before loop#34
Copilot wants to merge 1 commit intomasterfrom
copilot/analyze-wake-issues-and-mitigations

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

…fore loop

The GTK Display.sleep() had a race condition where the `wake` boolean
flag was reset to false inside the do-while loop (before each poll).
If wakeThread() was called between loop iterations, the wake=true
signal could be overwritten by wake=false, and the eventfd signal
consumed by g_main_context_check(), causing the sleep loop to miss
the wakeup and continue sleeping indefinitely.

Fixes:
1. Make `wake` field volatile for cross-thread visibility
2. Move `wake = false` before the loop (reset once, not per iteration)
3. Update BusyIndicator to use asyncExec instead of wake() for
   CompletionStage completion (defense in depth)
4. Correct the misleading "Bug in GTK" comment - the issue was in
   SWT's own code, not in g_main_context_wakeup()
5. Add analysis documentation

Fixes eclipse-platform#3044
Related: eclipse-platform#3053, eclipse-platform#3059, eclipse-platform#3060

Agent-Logs-Url: https://github.com/laeubi/eclipse.platform.swt/sessions/d50f4895-a7c1-40e0-991d-4121ed47a5e7

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
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