QFontDatabase causes Segfault [Solved]
-
Hello,
I was getting a segmentation fault out of the line
auto s = QFontDatabase::addApplicationFont("construct/Type.ttf");
and I wasn't sure why that was. After some testing, I tried the line
QFontDatabase k;
and I got a segmentation fault out of it, too. (Valgrind tells me there's something in the constructor that causes the segfault.) I don't understand. I'm including
<QFontDatabase>
and all. Any ideas?Thanks in advance.
-
Hi,
What does the debugger tell you ?
-
I mean: what is the stack trace when you run your application through the debugger ? In your case, gdb
-
I get this:
./Menu[0x4611fd] /lib/x86_64-linux-gnu/libpthread.so.0(+0x10340)[0x7fe46bebc340] /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5(+0x1743fa)[0x7fe46c8e43fa] /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN13QFontDatabaseC2Ev+0x41)[0x7fe46c8e4461] ./Menu[0x429172] ./Menu[0x412b3d] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fe46b26fec5] ./Menu[0x412f10]
-
You should run a debug build of your application, it will give more precise information.
-
Did you set these flags your self or use Qt Creator Run in debug mode ?
-
Try again with
CONFIG+=debug
. You currently build a debug version of your app running against a release build of Qt.You might not be using mutex directly but depending on what part of Qt you use, Qt is.
-
Do you have the Qt debug package for your distribution installed ?
-
@SGaist I've just installed
qtbase5-dbg
to make sure, but the result remains the same.Anyway, do we really need to get more information about what exactly is causing the segmentation fault in
QFontDatabase::QFontDatabase
? It seems that almost anything in<QFontDatabase>
causes a segmentation fault. Well, at leastQFontDatabase::QFontDatabase
andQFontDatabase::addApplicationFont
do. -
Wait, Valgrind seems to be more accurate than the stack trace for some reason.
==2786== at 0x672E3FA: initializeDb() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.2.1) ==2786== by 0x672E460: QFontDatabase::QFontDatabase() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.2.1)
I don't know how to get more info.
-
When are you using it in your application ?
-
int main(int argc, char *argv[]) { DS::Initialize(); \\ ... }
where
DS::Initialize
is a static function of the classDSĀ
:void DS::Initialize(void) { struct sigaction act; sigemptyset(&act.sa_mask); act.sa_handler = ::Handler; act.sa_flags = 0; sigaction(SIGSEGV, &act, 0); QFontDatabase k; std::cout << "foo" << std::endl; auto s = QFontDatabase::addApplicationFont("construct/Type.ttf"); std::cout << "foo" << std::endl; \\ ... }
-
You're missing a QGuiApplication in order to use QFontDatabase
-
You're welcome !
Just edit the thread title a prepend it or rather [solved] so that the forum can pick it up and modify the view accordingly :)