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. Segmentation fault in QApplication constractor

Segmentation fault in QApplication constractor

Scheduled Pinned Locked Moved General and Desktop
segmentation faqapplication co
11 Posts 2 Posters 4.1k Views
  • 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.
  • C Offline
    C Offline
    Coldman
    wrote on last edited by
    #1

    Hi guys!
    I get very strange segmentation fault in my Qt desctop GUI app.
    It is look like QApplication search execute file path and crash in this process, in Application constractor.
    I found, that this error depend with length of path to my execute. For example in folder /home/user/Projects/Qt/myProgram/Developmet
    it crash, but in folder /home/user launch normal.
    Needed to say, that other my projects dnt have this problem.
    I cant find reason of this error.
    Can someone halp me with this trouble?

    I use solaris cpp compiler with solaris studio in my Solaris OS, static build of Qt application.
    Qt version 4.6.1

    stack call of my program before crash:
    qAtomicAssignQFileInfoPrivate::Data(0x1, 0x8ea97d8, 0x26, 0x89ddd2c)
    QFileInfo::operator=(0x8045f54, 0x8045f24, 0x8045f40, 0x89ddd62)
    QFileInfo::setFile(0x8045f54, 0x8045f70, 0x0, 0x1)
    QFSFileEnginePrivate::canonicalized(0x8045ffc, 0x8046000, 0x3, 0x8a1b3c1)
    QFSFileEngine::fileName(0x804649c, 0x8ea83c0, 0x6, 0x89dd22e)
    QFileInfoPrivate::getFileName(0x804655c, 0x8ea83d0, 0x6, 0x89ddf84)
    QFileInfo::canonicalFilePath(0x804655c, 0x8046558, 0x8046578, 0x8a36f4d)
    QCoreApplication::applicationFilePath(0x80465ac, 0x8b29c98, 0x80465c8, 0x8a36d8e)
    QCoreApplication::applicationDirPath(0x80465f4, 0xf, 0x2f2387f, 0x896fc1e)
    QLibraryInfoPrivate::findConfiguration(0xfd3c3000, 0x8046620, 0x8046620, 0x8b29c98, 0x1, 0x8046430)
    QLibrarySettings::QLibrarySettings(0x8ea83b0, 0x0, 0x4000, 0x896fad6)
    qt_library_settings(0xfd3c3000, 0xfef1d81c, 0x1, 0x8046690, 0x1, 0x80464a0)
    QLibraryInfo::location(0x80467e4, 0x5, 0x8046828, 0x8a37b93)
    QCoreApplication::libraryPaths(0x804684c)
    QCoreApplication::init(0x8046a9c, 0x8ea7490, 0x0, 0x8a34b46)
    QCoreApplication::QCoreApplication(0x8046a9c, 0x8ea7490, 0x8046ad4, 0x1)
    QApplication::QApplication(0x8046a9c, 0x8046ab0, 0x8046ad4, 0x40601, 0x0, 0x0)
    main(argc = 1, argv = 0x8046ad4)

    main code:
    #include <QtGui/QApplication>
    #include "MainWindow.h" //main window header
    #include <QTextCodec>
    #include "definitions.h"* //file with VERSION and COMPILED constants*
    #include <iostream>

    int main(int argc, char *argv[]) {
    #ifdef COMPILED
    std::cerr<<"Compiled date and time: "<<COMPILED<<"\n";
    #endif
    #ifdef VERSION
    std::cerr<<"Current veriosn: "<<VERSION<<"\n";
    #endif
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QApplication app(argc, argv); //Failed here all rows before works correct in other projects
    MainWindow Form1;
    Form1.show();
    return app.exec();
    }

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

      Hi and welcome to devnet,

      I don't have any solaris system nor an old Qt version like that but from your code you're calling setCodecForTr and setCodecForCStrings too early. You need to first create the QApplication.

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

      C 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I don't have any solaris system nor an old Qt version like that but from your code you're calling setCodecForTr and setCodecForCStrings too early. You need to first create the QApplication.

        C Offline
        C Offline
        Coldman
        wrote on last edited by
        #3

        @SGaist thanks for your help. I chnaged my code, but this dnt help. I also use my exceptions in my project and multiple inheritance for one my class. My class inherits from simple class and QAbstractTableModel, and in header file of my class i declare
        class MyClass: public QAbstractTableModel, public SimpleClass
        {
        }

        May be reason is wrong generated code?

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

          What is SimpleClass ?

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

          C 1 Reply Last reply
          0
          • SGaistS SGaist

            What is SimpleClass ?

            C Offline
            C Offline
            Coldman
            wrote on last edited by
            #5

            @SGaist SimpleClass is a clas, that created by me. It dnt inherits from other classes, ie dnt have parent class. I use this for comynicate with some external program

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

              Does the crash also happen if you only have:

              QApplication app(argc, argv);
              QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
              QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
              return app.exec();
              

              in your main ?

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

              C 1 Reply Last reply
              0
              • SGaistS SGaist

                Does the crash also happen if you only have:

                QApplication app(argc, argv);
                QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
                QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
                return app.exec();
                

                in your main ?

                C Offline
                C Offline
                Coldman
                wrote on last edited by
                #7

                @SGaist yes, I'm sory, needed to send you my main code earlier.
                Look at my main code:
                #include <QtGui/QApplication>
                #include "MainWindow.h"
                #include <QTextCodec>
                #include "definitions.h"
                #include <iostream>

                int main(int argc, char *argv[]) {
                // initialize resources, if needed
                // Q_INIT_RESOURCE(resfile);
                #ifdef COMPILED
                std::cerr<<"Compiled date and time: "<<COMPILED<<"\n";
                #endif
                #ifdef VERSION
                std::cerr<<"Current veriosn: "<<VERSION<<"\n";
                #endif
                QApplication app(argc, argv);
                QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
                QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
                MainWindow Form1;
                Form1.show();
                return app.exec();
                }

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  Coldman
                  wrote on last edited by
                  #8

                  I think solution is to look to code, that compiler generate.
                  Douse anyone know how to decompile my object file?

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

                    Again: before trying to analyze the results of your compiler, can you run a default application ?

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

                    C 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Again: before trying to analyze the results of your compiler, can you run a default application ?

                      C Offline
                      C Offline
                      Coldman
                      wrote on last edited by
                      #10

                      @SGaist other projects run correct.
                      I get solution - use g++ compiler and gmake instead of solaris compiler and dmake.
                      My project work correct now

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

                        If you want to use the solaris compiler with Qt you probably have to first recompile Qt yourself. Anyway, switching to g++ is not a bad idea in this case.

                        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