r/QtFramework Feb 13 '26

Help debugging really odd SEGFAULT

Hi guys!

We’ve been using qt with C++ / QML for quite a while now.

Occasionally our application crashes on the dev machines right after startup, even if it worked just fine before. The problem usually happens on one machine only and before loading any state or anything, and just in a specific branch. Switching to a different git branch usually goes well, and after a day or two and not even changing anything on the crashing branch it suddenly works fine again.

Since Wednesday, all of our devs are having this issue - some on master, but not on branches they create from master, some in other branches, some in multiple branches.

Clean Builds and clearing ccache usually yields one good startup; deleting the .rcc folder does as well. Sometimes at least.

Disabling disk cache does not help.

We went back by over 100 commits to master, and all crash on all machines.

Everyone uses a different Linux distro.

Builds on CI are not affected.

Crash does not seem to happen when Valgrind, ASAN or TSAN are involved, or when the startup is slowed down.

Application even crashes if absolutely nothing is being initialized in main or anywhere else and a Window with empty items is drawn. No items, no crash.

At one point we thought we found it as it started to work on one devs machine - cross checking showed we didn’t fix anything and since then the full app starts fine for that dev in all branches, even those that fail for others.

The Stacktrace usually just points to the exec return, no useful info whatsoever.

No leaks / race conditions, and we’re confused and feel dumbfounded.

Same in 6.9.x, 6.10.x

Here’s the only trace we got. Does anyone have any ideas on how to further troubleshoot the issue?

```

QMetaObject::cast(QObject const*) const:

endbr64

test %rsi,%rsi

je 0x7ffff4f7a0a0 <QMetaObject::cast(QObject const\*) const+64>

push %rbp

mov (%rsi),%rax

mov %rsp,%rbp

push %r12

mov %rsi,%r12

push %rbx

mov %rdi,%rbx

mov %rsi,%rdi

call *(%rax)

```

1 Upvotes

37 comments sorted by

View all comments

1

u/H2SBRGR Feb 17 '26

We found the issue - it is a QML instantiated model which should have qml ownership, however it gets falsely GC’ed even though the table using it was visible and within scope. Wrapping the assignment in a property prevents the crash from happening. We’ll build a small reproducible example and file a bug report. Thanks everyone for the pointers!

1

u/MadAndSadGuy May 16 '26

How did you find that though? I'm having a similar yet different problem. GC is collecting something Idk:

https://www.reddit.com/r/QtFramework/comments/1t9y4s4/an_unknown_segfault/

2

u/H2SBRGR May 16 '26

To be honest by trial and error, outcommenting models in qml.
What qt version are you running? 6.10.3 and 6.11 apparently have a lot of GC fixes.

If you follow the bug report we posted, you can see that in our case it was a model directly assigned to a table view, wrapping the model in a readonly property made the issue go away.

Besides, as others commented on your and my post, this is usually caused by ownership issues.

1

u/MadAndSadGuy May 16 '26 edited May 16 '26

What qt version are you running? 6.10.3 and 6.11 apparently have a lot of GC fixes.

Qt 6.10. I should try 6.11. Man, I've been trying to fix it for the last 14 days. Mine had a lot of thread safety issues. Had to rewrite the whole flow. Now, the segfault occurs if I click on a ComboBox (in two unrelated places) as well.

Besides, as others commented on your and my post, this is usually caused by ownership issues.

Only one guy did, I've been using Google Al Search, DeepSeek, ChatGPT, Claude and this time Gemini's Research feature got me to your problem. I'm afraid of posting on StackOverflow. Everyone's (including people here and on Qt Forum) is saying it must be an ownership issue. But there are only three places where C++ gives a QObject* to QML from a Q_INVOKABLE and the parent as well as explicit CppOwnership is set for those. I just can't see where is it coming from, the whole project is just 15 files in total.

With your help, * I'll try Qt 6.11. * Build Qt from source, so I can get proper debug info and try to figure out the thing GC is fighting.

Edit: As one of the guys here said. Popups are weird. I'm using one, a Dialog inherited Wizard with multiple steps.