Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macOS segfault on close after hardware error #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Feb 1, 2021

  1. Use common event loop interrupt on hardware error.

    Just cleaning up the event info struct isn't enough: one some platforms,
    there's a “drain loop” thread which runs underneath the monitor thread
    to watch for an empty output buffer. This thread needs to be stopped,
    too, or it'll segfault and bring down the whole JVM after the event info
    struct is freed.
    MrDOS committed Feb 1, 2021
    Configuration menu
    Copy the full SHA
    557d93a View commit details
    Browse the repository at this point in the history
  2. Use a real read/write lock on the monitor thread.

    The old `MonitorThreadLock` boolean field was only checked at a very
    slow interval (5s!), and, itself not being synchronized, was prone to
    race conditions. More importantly, it wasn't set during the monitor
    thread's self-cleanup after hardware failure, so under typical access
    patterns, the monitor thread and the application thread would both try
    to clean up the monitor thread simultaneously. This race condition could
    occasionally lead to a segfault (only reproduced on macOS, but I've no
    doubt it could happen elsewhere).
    
    I've also attempted to clean up some redundant flag fields, and
    consolidate setting the remaining fields to further avoid
    concurrency/reentrancy issues.
    MrDOS committed Feb 1, 2021
    Configuration menu
    Copy the full SHA
    e53d7b6 View commit details
    Browse the repository at this point in the history