0

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    
rubenvb
  • 74,642
  • 33
  • 187
  • 332
user3917718
  • 85
  • 2
  • 13
  • What happens around line 50? Are the surrounding lines your code or are those OS functions? It's difficult to tell because it seems you've linked statically? – rubenvb Nov 08 '16 at 15:27
  • Just a side note: be aware that you cannot link statically with Qt when you develop a commercial product and do not have a commercial Qt License. You have to link dynamically. – Hayt Nov 08 '16 at 15:35
  • Related? https://bugreports.qt.io/browse/QTBUG-50744 – Simon Kraemer Nov 08 '16 at 15:38
  • looks like some memory corruption happens when you switch files, check with valgrind – Nikita Nov 08 '16 at 15:38
  • 2
    @Hayt - why not? Nothing in LGPL prohibits static linking. – dtech Nov 08 '16 at 15:51
  • @ddriver they direct you themselves to this when you go through the wizard on the website. https://www.qt.io/download/ Dynamic gets you the open source version and static to licensed when you are not willing to open source your own application. I just worked by what "Qt" intended. AFAIK you also can link statically but need to allow download of your object files so others can change the linked qt version (which is like never done) http://stackoverflow.com/questions/2277165/qt-single-exe-with-lgpl – Hayt Nov 08 '16 at 16:00
  • Don't know what function that is in line 50. However those are all OS or library functions. The only line relating to our code directly is 55. But that is app.exec() – user3917718 Nov 08 '16 at 16:04
  • 1
    You can't expect to be productive doing Qt development using prebuilt binaries. You must build Qt yourself - configure it for a debug&release build, and use the debug build to trace into the library and see what has failed. It's either a Qt bug, or a bug in your application that has corrupted the state of Qt's data and manifests thus. It'll be hard to say either way unless you are able to get a sensible backtrace, and step through the code. – Kuba hasn't forgotten Monica Nov 08 '16 at 16:11
  • 1
    @Hayt And what has that got to do with *anything* (correctness of the assertion aside)? Never mind that the project in question is GPLv2. Furthermore, your assertion "which is like never done" is unnecessary: to be in compliance with LGPL, it **must be done under the terms of the license itself**. This is wholly off-topic here anyway. – Kuba hasn't forgotten Monica Nov 08 '16 at 16:13
  • ok, I think we'll try the building Qt ourselves. Hope that will help trace the bug – user3917718 Nov 08 '16 at 16:36

1 Answers1

3

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