PCB Editor crashes on macOS with multiple displays during frame construction
Summary
The PCB Editor hard crashes with EXC_BAD_ACCESS on macOS when opening a board on a system with multiple displays (e.g. MacBook with an external monitor and lid with internal monitor opened). The crash occurs during PCB_EDIT_FRAME construction before the editor UI appears.
Steps to Reproduce
- Connect an external monitor to a MacBook (lid open)
- Open a KiCad project
- Open the PCB Editor
- Result: Crash with EXC_BAD_ACCESS
Note
This is a race condition entangled with macOS API and wx event routing, see explanation below. Reproduction may depend on some things like project window placement and monitor at which it opened up initially, so it may not be 10/10 cases depending on specific setup. Still, I encountered this during normal usage as a highly annoying thing, so I think just trying out without special care should reproduce this crash within a few tries for everyone.
Workaround
Close the MacBook lid and use only the external monitor or disconnect external monitors.
Root Cause
wxEVT_SYS_COLOUR_CHANGED is bound to onDarkModeToggle in the PCB_BASE_EDIT_FRAME constructor, but m_appearancePanel is not created until later in PCB_EDIT_FRAME construction. During LoadSettings(), LoadWindowState calls DoSetSize, which on macOS triggers a synchronous windowDidChangeBackingProperties notification when the window spans multiple displays. wxWidgets translates this into wxEVT_SYS_COLOUR_CHANGED, and the handler dereferences m_appearancePanel while it is still null.
Backtrace from lldb
Process 44843 launched: '/path/to/local/debug/kicad' (arm64)
2026-03-02 10:09:30.949934+0100 kicad[44843:1556781] [StateRestoration] -[NSApplication(NSWindowRestoration) restoreWindowWithIdentifier:state:completionHandler:] Unable to find className=(null)
[unrelated events ...]
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x340)
frame #0: _pcbnew.kiface`APPEARANCE_CONTROLS::OnDarkModeToggle(this=0x0000000000000000) at appearance_controls.cpp:1205:26
KiCad Version
Application: KiCad arm64 on arm64
Version: 10.0.0-rc1.1-602-g2c63082a3d, release build
Libraries:
wxWidgets 3.2.8
FreeType 2.14.1
HarfBuzz 12.3.2
FontConfig 2.17.1
libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.68.0
Platform: macOS Version 26.3 (Build 25D125), 64 bit, Little endian, wxMac
Build Info:
Date: Mar 2 2026 09:32:41
wxWidgets: 3.2.8 (wchar_t,wx containers)
Boost: 1.90.0
OCC: 7.9.3
Curl: 8.7.1
ngspice: 45.2
Compiler: Clang 17.0.0 with C++ ABI 1002
KICAD_IPC_API=ON
KICAD_USE_PCH=OFF