Skip to content

PopupWindow : Possible fix for obscure segfault#6905

Merged
murraystevenson merged 1 commit intoGafferHQ:1.6_maintenancefrom
danieldresser-ie:maybeUiCrashFix
Apr 24, 2026
Merged

PopupWindow : Possible fix for obscure segfault#6905
murraystevenson merged 1 commit intoGafferHQ:1.6_maintenancefrom
danieldresser-ie:maybeUiCrashFix

Conversation

@danieldresser-ie
Copy link
Copy Markdown
Contributor

@danieldresser-ie danieldresser-ie commented Apr 24, 2026

ImageEngine has found a weird crash in a specific UI, which has been fairly frequently causing problems. It involves using the Spreadsheet editor to create a popup window containing a VectorDataWidget, closing that, and then pressing a button that reloads the contents of a complicated dynamic box, triggering UI refreshes that take quite a while to complete.

I've emailed John some crash logs to look at.

Martin and Ivan were able to track this down to having started happening in 1.6.4, and more specifically, this commit:
a13abf4

Looking at that without much context, and not being that familiar with this use of __get__, it looks to me like it is creating a circular reference to _qtWidget() that would result in being kept alive until garbage collection. I'm not sure whether that should be a problem, but it seems plausible that it could be at least the trigger for this crash, even if it isn't wrong.

The result of a __get__ seems a lot like a method, so I suggested wrapping it in a WeakMethod to see what happens. In Ivan's testing, that seems to have stopped him seeing the crash. I have no idea if this is actually correct, or if it could cause other problems, but I figured I'd PR it in case it seems reasonable. If we can find a fix for this issue, it would be great to release it quickly.

If we're completely barking up the wrong tree here, and John doesn't spot anything likely in the crash logs, then we might need to try and reproduce this outside the IE env, but that could be quite tricky, given that it seems to be dependent on the specific timing of loading a complex setup using a custom UI.

As the new unit test demonstrates, this can lead to PySide crashes if the widget is later garbage collected on a background thread. We believe this test models crashes that we have seen both at Image Engine and Cinesite. In Image Engine's case the popup was commonly in a Spreadsheet, and in Cinesite's case the common trigger seemed to have been a custom render pass name widget that the RenderPassEditor pops up.

The circular reference was caused by a13abf4, where I claimed to be "using a regular function rather than a method". But what I failed to understand was that `__get__` was actually creating a bound method, and hence a circular reference. The solution is to revert to the original code, using WeakMethod to avoid the circular reference. This has the problem that motivated the change in the first place though - warnings about an expired WeakMethod when closing a popup editor in VectorDataWidget. This time we fix them by passing `fallbackResult = None` to WeakMethod, so it doesn't complain about expiration.
@johnhaddon
Copy link
Copy Markdown
Member

@danieldresser-ie, @ivanimanishi, @mortimerb thank you so much for tracking this one down. I have been hunting it for months at Cinesite but never got a reliable repro. I'm pretty sure it's the same thing though - same stack trace, and we recently started to suspect that a PopupWindow was involved.

@danieldresser-ie, I think your fix is totally legit, but I've pushed an alternative version that does a fuller revert of a13abf4, includes a unit test that proves the crash is fixed, and has more discussion in the commit message. If that looks OK to you then let's get this into a release today.

@danieldresser-ie
Copy link
Copy Markdown
Contributor Author

LGTM

@murraystevenson murraystevenson merged commit 74aec87 into GafferHQ:1.6_maintenance Apr 24, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Pending Review to Pending release in Work in Progress Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pending release

Development

Successfully merging this pull request may close these issues.

3 participants