test: Nudge toward QT_STYLE_OVERRIDE=fusion on macOS
What changed, and why it matters
This change only affects Bitcoin Core's own Qt graphical-interface test suite on macOS. It forces the tests to use Qt's 'Fusion' style instead of the native Mac style, because the native Mac style can crash when running in the minimal test environment. It is a test-only hardening fix, not a change to the live Bitcoin wallet or network code that ordinary users run.
No urgent action for end users or node operators; this is a test-only reliability fix. Developers running Qt tests on macOS should ensure the change is present to avoid flaky or crashing GUI tests. Consider monitoring upstream Qt for a proper fix to QTBUG-49686.
Security signals we found
Null-pointer dereference crash avoided in Qt test code
Workaround for upstream Qt bug QTBUG-49686
Test-only change; no production wallet/network code modified
Environment variable override to use non-native Qt style
Evidence from the diff
The commit adds a macOS-only environment variable override in src/qt/test/test_main.cpp: QT_STYLE_OVERRIDE=fusion. The Qt minimal QPA platform used during automated GUI tests does not provide a Cocoa NSWindow/NSView, so QMacStyle can dereference a null native view when painting widgets such as QGroupBox (Qt bug QTBUG-49686). Switching to the Fusion style avoids native Mac widget rendering and therefore avoids the nullptr dereference in the test binary.
Changed components
src/qt/test/test_main.cppBitcoin Core Qt GUI test runner on macOSInspect captured patch +6 / −0
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index 1a0f3c7b..62e132e8 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -66,6 +66,12 @@ int main(int argc, char* argv[])
setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */);
#endif
+#ifdef Q_OS_MACOS
+ // QMacStyle assumes a Cocoa platform window, which the minimal platform
+ // does not provide. In particular, painting a QGroupBox can make Qt call
+ // addSubview: on an invalid native object (QTBUG-49686).
+ setenv("QT_STYLE_OVERRIDE", "fusion", 0 /* overwrite */);
+#endif
QCoreApplication::setOrganizationName(QAPP_ORG_NAME);
QCoreApplication::setApplicationName(QAPP_APP_NAME_DEFAULT "-test");
Why this scored 27/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.