user3917718 user3917718 - 24 days ago 15
C++ Question

Cannot trace cause of crash in Qt program

we are developing a raw data video player in Qt (https://github.com/IENT/YUView/). We recently came across a problem where our player crashes. We were unable to trace the cause in the debugger, it seems to happen somewhere in the Qt internals, see the trace below.

Basically we have a problem of how to look for the problem. Any idea on how to approach that?

The problem happens only on Linux machines (already tested different Qt versions), not on Windows. It is related to opening and switching between some files, but it only happens sometimes, we cannot trigger it intentionally, rather have to switch between files many times until it occurs. That can be immediately or after minutes.

Here is the trace of the problem:

0 QFontEngineFT::loadGlyphSet /usr/lib/debug/.build-id/c9/2e9e9dc3a4cf1f0133535e22d8ad76aa855d38.debug 1338 0x7fffeeed597a
1 QFontEngineFT::loadGlyphFor /usr/lib/debug/.build-id/c9/2e9e9dc3a4cf1f0133535e22d8ad76aa855d38.debug 1795 0x7fffeeed59f8
2 QFontEngineFT::lockedAlphaMapForGlyph /usr/lib/debug/.build-id/c9/2e9e9dc3a4cf1f0133535e22d8ad76aa855d38.debug 1763 0x7fffeeed6ac4
3 QRasterPaintEngine::drawCachedGlyphs /usr/lib/debug/.build-id/81/2089dc48198b2723d82741c41011f463a732c0.debug 2760 0x7ffff75280f1
4 QRasterPaintEngine::drawTextItem /usr/lib/debug/.build-id/81/2089dc48198b2723d82741c41011f463a732c0.debug 3036 0x7ffff752ac5f
5 QPainterPrivate::drawTextItem /usr/lib/debug/.build-id/81/2089dc48198b2723d82741c41011f463a732c0.debug 6500 0x7ffff75482d1
6 QTextLine::draw /usr/lib/debug/.build-id/81/2089dc48198b2723d82741c41011f463a732c0.debug 2532 0x7ffff73d5c5d
7 QTextLayout::draw /usr/lib/debug/.build-id/81/2089dc48198b2723d82741c41011f463a732c0.debug 1192 0x7ffff73d6a0d
8 QWidgetLineControl::draw /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 629 0x7ffff7a8240b
9 QLineEdit::paintEvent /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 1986 0x7ffff79f6038
10 QWidget::event /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 9044 0x7ffff78e7f88
11 QLineEdit::event /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 1456 0x7ffff79fb349
12 QApplicationPrivate::notify_helper /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 3716 0x7ffff78a505c
13 QApplication::notify /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 3499 0x7ffff78aa516
14 QCoreApplication::notifyInternal /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 965 0x7ffff6fb238b
15 QCoreApplication::sendSpontaneousEvent /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 227 0x7ffff78e0a79
16 QWidgetPrivate::sendPaintEvent /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5625 0x7ffff78e0a79
17 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5565 0x7ffff78e10c1
18 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5760 0x7ffff78e1d6c
19 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5617 0x7ffff78e0c31
20 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5760 0x7ffff78e1d6c
21 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
22 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
23 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
24 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
25 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
26 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5617 0x7ffff78e0c31
27 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5760 0x7ffff78e1d6c
28 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5617 0x7ffff78e0c31
29 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5760 0x7ffff78e1d6c
30 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5617 0x7ffff78e0c31
31 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5760 0x7ffff78e1d6c
32 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5617 0x7ffff78e0c31
33 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5760 0x7ffff78e1d6c
34 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
35 QWidgetPrivate::paintSiblingsRecursive /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5747 0x7ffff78e1c59
36 QWidgetPrivate::drawWidget /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 5617 0x7ffff78e0c31
37 QWidgetBackingStore::doSync /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 1226 0x7ffff78b28aa
38 QWidgetBackingStore::sync /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 1032 0x7ffff78b2a8c
39 QWidgetPrivate::syncBackingStore /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 1902 0x7ffff78d0c1f
40 QWidget::event /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 8983 0x7ffff78e7d88
41 QMainWindow::event /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 1495 0x7ffff79fdd7b
42 QApplicationPrivate::notify_helper /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 3716 0x7ffff78a505c
43 QApplication::notify /usr/lib/debug/.build-id/d5/2143d1747e6970d9ecdc0538c5c9170af15963.debug 3499 0x7ffff78aa516
44 QCoreApplication::notifyInternal /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 965 0x7ffff6fb238b
45 QCoreApplication::sendEvent /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 224 0x7ffff6fb4786
46 QCoreApplicationPrivate::sendPostedEvents /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 1593 0x7ffff6fb4786
47 QCoreApplication::sendPostedEvents /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 1451 0x7ffff6fb4c68
48 postEventSourceDispatch /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 271 0x7ffff70083c3
49 g_main_context_dispatch 0x7ffff57691a7
50 ?? 0x7ffff5769400
51 g_main_context_iteration 0x7ffff57694ac
52 QEventDispatcherGlib::processEvents /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 418 0x7ffff70087cf
53 QEventLoop::exec /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 204 0x7ffff6fafb4a
54 QCoreApplication::exec /usr/lib/debug/.build-id/53/070dadaef9fa7fb45640b17d77ee3aeeac7b13.debug 1229 0x7ffff6fb7bec
55 main yuviewapp.cpp 84 0x4b16e9

Answer

The segfault happens in QFontEngineFT::loadGlyphSet(const QTransform &matrix) at line 1338 in Qt 5.5.

1334 if (matrix.type() > QTransform::TxShear || !cacheEnabled)
1335    return 0;
1336
1337 // FT_Set_Transform only supports scalable fonts
1338 if (!FT_IS_SCALABLE(freetype->face))
1339    return matrix.type() <= QTransform::TxTranslate ? &defaultGlyphSet : Q_NULLPTR;

IMHO this is a bug in Qt and it is not fixed in Qt 5.7 yet. However, one possible workaround could be to force the return statement to happen. This could be done by setting the following environment varibale:

export QT_NO_FT_CACHE=1
Comments