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

Disable Mach exception handlers when read barriers in place #5991

Merged

Commits on Jun 12, 2022

  1. Disable Mach exception handlers when read barriers in place

    The GC compaction mechanism implements a kind of read barrier by marking
    some (OS) pages as unreadable, and installing a SIGBUS/SIGSEGV handler
    to detect when they're accessed and invalidate an attempt to move the
    object.
    
    Unfortunately, when a debugger is attached to the Ruby interpreter on
    Mac OS, the debugger will trap the EXC_BAD_ACCES mach exception before
    the runtime can transform that into a SIGBUS signal and dispatch it.
    Thus, execution gets stuck; any attempt to continue from the debugger
    re-executes the line that caused the exception and no forward progress
    can be made.
    
    This makes it impossible to debug either the Ruby interpreter or a C
    extension whilst compaction is in use.
    
    To fix this, we disable the EXC_BAD_ACCESS handler when installing the
    SIGBUS/SIGSEGV handlers, and re-enable them once the compaction is done.
    The debugger will still trap on the attempt to read the bad page, but it
    will be trapping the SIGBUS signal, rather than the EXC_BAD_ACCESS mach
    exception. It's possible to continue from this in the debugger, which
    invokes the signal handler and allows forward progress to be made.
    KJTsanaktsidis committed Jun 12, 2022
    Configuration menu
    Copy the full SHA
    6276a29 View commit details
    Browse the repository at this point in the history