Skip to content

macOS: closing Parameters dialog can crash REAPER restoring stale prevFocus #1452

Description

@jayladdermusic

Summary

On macOS, closing OSARA's Parameters dialog can crash REAPER while ParamsDialog::~ParamsDialog() tries to restore focus to the window/control that was focused when the dialog opened.

This occurred twice with effectively identical stacks, so it does not look like a random one-off crash.

Environment

  • macOS 26.6 (25G72)
  • Apple silicon / arm64
  • REAPER 7.76 (7.76.0_6cb0d69u)
  • Installed OSARA: 2026.8.20.2324,018e2094
  • Also inspected current snapshot/source: 2026.8.29.2333,dd330f65

Crash signature

First occurrence:

EXC_BAD_ACCESS / SIGSEGV
KERN_INVALID_ADDRESS at 0x0000000049444948

lookUpImpOrForward
_objc_msgSend_uncached
SetFocus(HWND__*)
ParamsDialog::~ParamsDialog()
ParamsDialog::~ParamsDialog()
ParamsDialog::dialogProc(HWND__*, unsigned int, unsigned long, long)
SwellDialogDefaultWindowProc(HWND__*, unsigned int, unsigned long, long)
-[REAPERapp sendEvent:]

Second occurrence:

EXC_BAD_ACCESS / SIGSEGV
KERN_INVALID_ADDRESS at 0x0000000000000010

objc_msgSend
SetFocus(HWND__*)
ParamsDialog::~ParamsDialog()
ParamsDialog::~ParamsDialog()
ParamsDialog::dialogProc(HWND__*, unsigned int, unsigned long, long)
SwellDialogDefaultWindowProc(HWND__*, unsigned int, unsigned long, long)
-[REAPERapp sendEvent:]

In the second crash, SetFocus was sending isKindOfClass: with NSWindow as the class argument when Objective-C faulted.

Analysis

ParamsDialog captures the focused HWND in its constructor:

this->prevFocus = GetFocus();

The destructor checks only whether the value is non-null before passing it to SetFocus:

if (this->prevFocus) {
    SetFocus(this->prevFocus);
}

The stacks and differing invalid addresses are consistent with prevFocus being non-null but referring to a destroyed/replaced SWELL/macOS window object by the time the dialog closes.

The latest source at dd330f65 appears to retain this focus-restoration code, so the newer snapshot might still be affected. I have not yet reproduced the crash on that snapshot.

A possible direction would be validating the stored HWND before restoring focus (for example with IsWindow) and using a safe fallback if it is no longer valid.

Reproduction status

I do not yet have a minimal deterministic sequence. Both observed crashes occurred on Parameters-dialog teardown and have the same OSARA/REAPER stack. The likely trigger is that the control or window which had focus before opening the Parameters dialog was destroyed or replaced while the dialog remained open.

This might be related in broad terms to #302, but that older issue was resolved in 2020 and did not include this specific stale-focus stack.

I can provide the full Apple .ips reports if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions