Fix attach crash on complex Qt applications#1125
Fix attach crash on complex Qt applications#1125Kevinye0116 wants to merge 3 commits intoKDAB:masterfrom
Conversation
|
|
for more information, see https://pre-commit.ci
|
can we get a test that reproduces the problem ? |
I tried attaching GammaRay to Insta360 Studio, and it crashed at first. The issue has been resolved after the modifications. The Quick Scenes interface experiences noticeable lag when loading some QML components, and the issue is still unresolved. |
I have already signed the CLA. |
Problem
When attaching GammaRay to complex Qt applications (e.g., apps using
Qt Quick, QQuickWindow, QSettings, etc.), the target process crashes
with an access violation in
Qt6Core!QSettings::d_func(nullthispointer). Simple applications were unaffected, and Launch mode worked
correctly in all cases.
Root cause:
gammaray_probe_attach()was not callingHooks::installHooks()orProbe::startupHookReceived(), leavingthe probe without real-time object lifecycle tracking during
findExistingObjects()traversal. This caused access to freed/invalidobjects in multi-threaded complex applications.
Changes
probe/hooks.cpp
Hooks::installHooks()call ingammaray_probe_attach()toregister Qt object creation/destruction hooks, consistent with the
Launch mode flow.
Probe::startupHookReceived()call to settrackDestroyed = false, preventing unsafe destruction tracking during initial objectdiscovery.
core/probe.cpp
Probe::discoverObject().m_validObjects.contains(child)check to skip already-discovered objects and prevent redundant recursive traversal.
foreachwith range-based for loop.plugins/quickinspector/quickinspector.cpp
view->engine(),window->contentItem(),and
children.first()inQuickInspector::objectCreated()toguard against partially-initialized QQuickWindow states during
attach-time object discovery.
Testing
Known Remaining Issues
unresponsiveness over time with high-throughput applications.
large number of top-level QObjects.
These are tracked but not addressed in this PR.