← Back to Pull requests

Fix potential initialization/termination deadlock in nvdaHelperRemote. #20297

Closed
unknown closed this pull request without merging on Jun 17, 2026 02:08 UTC
View on GitHub
unknown unknown commented on Jun 08, 2026 10:12 UTC
Author

Link to issue number:


Re #19292.

Summary of the issue:


1. When nvdaHelperRemote initializes in the application's UI thread, it sets up a new manager thread.
2. That thread waits on a mutex to guarantee that only one of these manager threads runs at any given time.
3. The UI thread waits until the new manager thread is initialized.
4. If an old manager thread is terminating, that thread (which still holds the mutex in (2)) might try to post a window message to the UI thread to terminate IA2 support and then waits for that termination to complete.
5. But the UI thread is blocked because of (3), which is blocked because of (2), which is blocked because of (4).
6. Deadlock!

This deadlock occurs infrequently, but I'm fairly sure it has been spotted in the wild. We have a timeout of 10 seconds for these waits, so we deadlock for a maximum of 10 seconds. This deadlock is most visible when it occurs in Explorer, since alt+tab won't be reported properly for at least 10 seconds after restarting NVDA.

Furthermore, this deadlock prevents us from enabling IA2 support in Windows Store applications, which was the workaround implemented for this deadlock in #5417. However, the inability to enable IA2 support for Windows Store applications causes problems like #19292.

Description of user facing changes:


None, as it isn't clear when this occurs, even though there's potential for it. This is a correctness fix, as well as paving the way for a future fix for #19292.

Description of development approach:


1. Make IA2Support_inProcess_terminate use execInThread instead of its own window message. It needs to wait for execution in the target thread, which is functionality that execInThread already provides.
2. Make it possible for injection.cpp to access wm_execInThread.
3. In initInprocManagerThreadIfNeeded, while waiting for the manager thread to initialize, dispatch wm_execInThread messages only. This ensures that a previous instance of nvdaHelperRemote can uninstall IA2 support on the UI thread without causing a deadlock.

Testing strategy:


I ran a try build on multiple machines with fairly solid usage for multiple hours across multiple days and encountered no problems. This included using Firefox, which is a very heavy IAccessible2 app. @michaelDCurran has also run the build for several days with no problems.

Known issues with pull request:


None known.

Code Review Checklist:

  • Documentation:

  • - Change log entry
    - User Documentation
    - Developer / Technical Documentation
    - Context sensitive help for GUI changes
  • Testing:

  • - Unit tests
    - System (end to end) tests
    - Manual testing
  • UX of all users considered:

  • - Speech
    - Braille
    - Low Vision
    - Different web browsers
    - Localization in other languages / culture than English
  • API is compatible with existing add-ons.

  • Security precautions taken.
  • Diff: 368 lines (+276 / -92) across 4 files Reviewer: jcsteh Review duration: 12476m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 368 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20297"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%
    Repository