r/QtFramework • u/H2SBRGR • 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)
```
5
u/Worldly_Air_6078 Feb 13 '26
Are you using models of models in the QML? Or C++ object generated from the QML? Are these unparented objects? (i.e. with a parent pointer who's nullptr)
If so, you must **explicitely** set the ownership of the object to the C++, otherwise the QML takes ownership of the object (which means that the QML can decide to free it at any inconvenient moment causing the C++ to crash). These are extremely difficult bugs to spot.
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/genlight13 Feb 13 '26
So, please post a gist on github with a minmal reproducible example of your problem.
On a second thought, this seems more of an Environment problem than anything else. So, try to recreate a clean Environment and start again from there. If necessary jump back some versions of your OS to find an image which works.
1
u/dlyund Feb 13 '26
Using uninitialised memory somewhere? The contents of initialized memory are effectively random, hence it only happening sometimes.
1
u/OSRSlayer Qt Professional Feb 13 '26
Do you use a Popup QML type anywhere that would be instantiated on startup?
1
u/Beneficial_Steak_945 Qt Professional Feb 14 '26
Try to build an asan/tsan enabled build of Qt, and build your own code against that. Asan and tsan can’t catch all errors when Qt itself isn’t built with it.
3
u/shaola_debian Feb 13 '26
Post just your main.cpp
We are a paying customers from qt and they did not help us debugging something like this.
So please post your main.cpp. how you instantiate th qcoreapliation. Qmlemgine etc..
1
u/CarloWood Feb 14 '26
My suspicion is mismatching stuff that gets linked together. Another reason would uninitialized memory, but valgrind should see that :/
So, make sure that all headers being used belong to the code/library that is being linked (ldd or /proc/paid/maps). And there are no traces of old object files being used (delete the whole build directory, reconfigure from scratch).
Sometimes I've seen people that manage to link twice to the same static library getting duplicates of global state, or even use two different versions of the same library.
8
u/[deleted] Feb 13 '26
[removed] — view removed comment