Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFontDatabase causes Segfault [Solved]
Forum Updated to NodeBB v4.3 + New Features

QFontDatabase causes Segfault [Solved]

Scheduled Pinned Locked Moved General and Desktop
19 Posts 2 Posters 6.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS SGaist

    Hi,

    What does the debugger tell you ?

    P Offline
    P Offline
    Pippin
    wrote on last edited by
    #3

    @SGaist What do you mean?

    Valgrind says

    ==5551==    at 0x672E3FA: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.2.1)
    ==5551==    by 0x672E460: QFontDatabase::QFontDatabase() (in /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.2.1)
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #4

      I mean: what is the stack trace when you run your application through the debugger ? In your case, gdb

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Pippin
        wrote on last edited by
        #5

        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]
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #6

          You should run a debug build of your application, it will give more precise information.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          P 1 Reply Last reply
          0
          • SGaistS SGaist

            You should run a debug build of your application, it will give more precise information.

            P Offline
            P Offline
            Pippin
            wrote on last edited by
            #7

            @SGaist I'm already compiling with QMAKE_CXXFLAGS += -std=c++14 -Wall -Wextra -pedantic -g -ggdb -rdynamic, what exactly would you like me to do?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Did you set these flags your self or use Qt Creator Run in debug mode ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Pippin
                wrote on last edited by Pippin
                #9

                I set these flags myself, I never use Qt Creator for anything. I compile and run everything through the terminal with qmake and make

                There was also this line though: QMutex: destroying locked mutex but I'm not using any mutex.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  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.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  P 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    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.

                    P Offline
                    P Offline
                    Pippin
                    wrote on last edited by
                    #11

                    @SGaist I've added CONFIG+=debug in the .pro file but the outcome is the same.:S

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      Do you have the Qt debug package for your distribution installed ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      P 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Do you have the Qt debug package for your distribution installed ?

                        P Offline
                        P Offline
                        Pippin
                        wrote on last edited by
                        #13

                        @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 least QFontDatabase::QFontDatabase and QFontDatabase::addApplicationFont do.

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          Pippin
                          wrote on last edited by Pippin
                          #14

                          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.

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            When are you using it in your application ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            P 1 Reply Last reply
                            0
                            • SGaistS SGaist

                              When are you using it in your application ?

                              P Offline
                              P Offline
                              Pippin
                              wrote on last edited by Pippin
                              #16

                              @SGaist

                              int main(int argc, char *argv[])
                              {
                              	DS::Initialize();
                              	\\ ...
                              }
                              

                              where DS::Initialize is a static function of the class DSĀ :

                              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;
                              	\\ ...
                              }
                              
                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                You're missing a QGuiApplication in order to use QFontDatabase

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                P 1 Reply Last reply
                                1
                                • SGaistS SGaist

                                  You're missing a QGuiApplication in order to use QFontDatabase

                                  P Offline
                                  P Offline
                                  Pippin
                                  wrote on last edited by Pippin
                                  #18

                                  @SGaist So it was only a matter of order! It works now, thank you so much! How do I add <Solved> ?

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #19

                                    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 :)

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved