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. Application crash on startup
Forum Updated to NodeBB v4.3 + New Features

Application crash on startup

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 581 Views 1 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I'm porting an application from Qt 4.8 to Qt 5.8, I've now got the application building with no issues, however on startup the application crashes.

    I've single stepped using the debugger however I'm still none the wiser as to what the error that is displayed means. Its a very reliable crash and this is the code from main:

    int main(int argc, char *argv[])
    {
        enum APP_NAME {
            APP_NAME_BASE,
            APP_NAME_UI,
            APP_NAME_PARTS };
        QScopedPointer<ExceptionHandlingQApplication> app(new ExceptionHandlingQApplication(argc, argv));
        QString appName = QApplication::applicationName();
        QStringList appNameList = appName.split("U");
        Q_ASSERT_X(appNameList.length()==APP_NAME_PARTS, "main()", "Expecting U in application name!");
        // Ensure the second element contains UI
        appNameList[APP_NAME_UI] = "UI";
        ///////////////////////////////////////////////////
        // Get something logged so we know it started
        qDebug().noquote() << QDateTime::currentDateTimeUtc().toString("ddd dd MMM yyyy - hh:mm:ss ")
                 << "////////////// Starting" << appName << "///////////////" ;
        qDebug() << "Version:" << PART_INFO << VERSION_INFO << BUILD_INFO << DATE_INFO;
        
        // Register custom debug handler
        //    qInstallMessageHandler(Debug::customDebugProcessor);
        //This is very annoying.
        //The LoadLibrary call Qt uses will call this again
        //I'm re setting it before we actually start the app down below
        //But we could nuke the function once we're done by making it a return 0;
        //http://chadaustin.me/2009/03/disabling-functions/
        //If any libs are loaded during runtime we may lose the hook :(
        SetUnhandledExceptionFilter(unhandled_handler);
        
        //suppress the "an error has occurred" boxes in release mode
        //The error handler will still catch the crash and dump, but we don't want customers to see it.
        //We have a batch wrapper around the exe which will restart it.
    #ifdef SUPPRESS_ERROR_DIALOG
        DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX); //to find out what the setting was
        SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX); //take what it was and OR in our new addition
    #endif
        
        SignalHandlerPointer previousSignalHandler;
        previousSignalHandler = signal(SIGABRT, SignalHandler);
        
        qmlRegisterType<QsltCursorShapeArea>("MyTools", 1, 0, "QsltCursorShapeArea");
        qmlRegisterType<FeedControlItem>("MyTools", 1, 0, "FeedControlItem");
        
        qmlRegisterUncreatableType<Calibration::CalibrationModel>("MyTools", 1, 0, "CalibrationModel", "Attempt to create CalibrationModel from QML");
        qmlRegisterType<Process>("MyTools", 1, 0, "Process");
        REGISTERMETATYPE(Process::ProcessState);
        
        qmlRegisterType<CacheProxyListModel>(appNameList[APP_NAME_BASE].toLatin1(), 1, 0, "CacheProxyListModel");
        qmlRegisterType<ProxyProperty>(appNameList[APP_NAME_BASE].toLatin1(), 1, 0, "ProxyProperty");
        
        // Is there a better place to register global metatypes?
        REGISTERMETATYPE(QStringList);
        
        // This is the UI
        QQuickView view;
    

    With a breakpoint set on the last line, everything is ok, stepping over the last line results in this:
    995a957f-e330-40bb-99fd-87b97bd98786-image.png

    I've also just tried simplifying and doing just this:

    int main(int argc, char *argv[])
    {
        enum APP_NAME {
            APP_NAME_BASE,
            APP_NAME_UI,
            APP_NAME_PARTS };
        QScopedPointer<ExceptionHandlingQApplication> app(new ExceptionHandlingQApplication(argc, argv));
        QString appName = QApplication::applicationName();
        QStringList appNameList = appName.split("U");
        Q_ASSERT_X(appNameList.length()==APP_NAME_PARTS, "main()", "Expecting U in application name!");
        // Ensure the second element contains UI
        appNameList[APP_NAME_UI] = "UI";
    
        // This is the UI
        QQuickView view;
    

    The result is the same:
    e821be44-a539-4463-bc40-801678b929d3-image.png

    This is also displayed in the Issues panel:
    f:\dd\vctools\crt\crtw32\string\i386\strcmp.asm:82: error: Exception at 0x52b94280, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)

    Kind Regards,
    Sy

    JonBJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I'm porting an application from Qt 4.8 to Qt 5.8, I've now got the application building with no issues, however on startup the application crashes.

      I've single stepped using the debugger however I'm still none the wiser as to what the error that is displayed means. Its a very reliable crash and this is the code from main:

      int main(int argc, char *argv[])
      {
          enum APP_NAME {
              APP_NAME_BASE,
              APP_NAME_UI,
              APP_NAME_PARTS };
          QScopedPointer<ExceptionHandlingQApplication> app(new ExceptionHandlingQApplication(argc, argv));
          QString appName = QApplication::applicationName();
          QStringList appNameList = appName.split("U");
          Q_ASSERT_X(appNameList.length()==APP_NAME_PARTS, "main()", "Expecting U in application name!");
          // Ensure the second element contains UI
          appNameList[APP_NAME_UI] = "UI";
          ///////////////////////////////////////////////////
          // Get something logged so we know it started
          qDebug().noquote() << QDateTime::currentDateTimeUtc().toString("ddd dd MMM yyyy - hh:mm:ss ")
                   << "////////////// Starting" << appName << "///////////////" ;
          qDebug() << "Version:" << PART_INFO << VERSION_INFO << BUILD_INFO << DATE_INFO;
          
          // Register custom debug handler
          //    qInstallMessageHandler(Debug::customDebugProcessor);
          //This is very annoying.
          //The LoadLibrary call Qt uses will call this again
          //I'm re setting it before we actually start the app down below
          //But we could nuke the function once we're done by making it a return 0;
          //http://chadaustin.me/2009/03/disabling-functions/
          //If any libs are loaded during runtime we may lose the hook :(
          SetUnhandledExceptionFilter(unhandled_handler);
          
          //suppress the "an error has occurred" boxes in release mode
          //The error handler will still catch the crash and dump, but we don't want customers to see it.
          //We have a batch wrapper around the exe which will restart it.
      #ifdef SUPPRESS_ERROR_DIALOG
          DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX); //to find out what the setting was
          SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX); //take what it was and OR in our new addition
      #endif
          
          SignalHandlerPointer previousSignalHandler;
          previousSignalHandler = signal(SIGABRT, SignalHandler);
          
          qmlRegisterType<QsltCursorShapeArea>("MyTools", 1, 0, "QsltCursorShapeArea");
          qmlRegisterType<FeedControlItem>("MyTools", 1, 0, "FeedControlItem");
          
          qmlRegisterUncreatableType<Calibration::CalibrationModel>("MyTools", 1, 0, "CalibrationModel", "Attempt to create CalibrationModel from QML");
          qmlRegisterType<Process>("MyTools", 1, 0, "Process");
          REGISTERMETATYPE(Process::ProcessState);
          
          qmlRegisterType<CacheProxyListModel>(appNameList[APP_NAME_BASE].toLatin1(), 1, 0, "CacheProxyListModel");
          qmlRegisterType<ProxyProperty>(appNameList[APP_NAME_BASE].toLatin1(), 1, 0, "ProxyProperty");
          
          // Is there a better place to register global metatypes?
          REGISTERMETATYPE(QStringList);
          
          // This is the UI
          QQuickView view;
      

      With a breakpoint set on the last line, everything is ok, stepping over the last line results in this:
      995a957f-e330-40bb-99fd-87b97bd98786-image.png

      I've also just tried simplifying and doing just this:

      int main(int argc, char *argv[])
      {
          enum APP_NAME {
              APP_NAME_BASE,
              APP_NAME_UI,
              APP_NAME_PARTS };
          QScopedPointer<ExceptionHandlingQApplication> app(new ExceptionHandlingQApplication(argc, argv));
          QString appName = QApplication::applicationName();
          QStringList appNameList = appName.split("U");
          Q_ASSERT_X(appNameList.length()==APP_NAME_PARTS, "main()", "Expecting U in application name!");
          // Ensure the second element contains UI
          appNameList[APP_NAME_UI] = "UI";
      
          // This is the UI
          QQuickView view;
      

      The result is the same:
      e821be44-a539-4463-bc40-801678b929d3-image.png

      This is also displayed in the Issues panel:
      f:\dd\vctools\crt\crtw32\string\i386\strcmp.asm:82: error: Exception at 0x52b94280, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @SPlatten said in Application crash on startup:

      I'm porting an application from Qt 4.8 to Qt 5.8

      The first question would be why 5.8 rather than a more recent version?

      1 Reply Last reply
      0
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @JonB , thats not my decision, its the newest version the company I'm on contract to is using.

        Kind Regards,
        Sy

        J.HilkJ 1 Reply Last reply
        2
        • SPlattenS SPlatten

          @JonB , thats not my decision, its the newest version the company I'm on contract to is using.

          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @SPlatten well, have you tried stepping in (F11 on windows and QTC) instead of stepping over (F10) ?🤔


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          SPlattenS 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @SPlatten well, have you tried stepping in (F11 on windows and QTC) instead of stepping over (F10) ?🤔

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #5

            @J-Hilk I’ll take another look tomorrow, taking a break from it now.

            Kind Regards,
            Sy

            1 Reply Last reply
            0
            • SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by SPlatten
              #6

              @J-Hilk , back on it this morning and single stepped every line stepping into where possible.

              Nothing looks wrong, I cannot single step into:

              QQuickView view;
              

              It still crashes with the same Exception Triggered dialog.

              I then reduced the code even more:

              int main(int argc, char *argv[])
              {
                  QApplication app(argc, argv);
                  // This is the UI
                  QQuickView view;
              

              And this doesn't crash so it would appear to be something thats done in:

              QScopedPointer<ExceptionHandlingQApplication> app(new ExceptionHandlingQApplication(argc, argv));
              

              Which I replaced with just:

              QApplication app(argc, argv);
              

              I'm not sure why a QScopedPointer is used at all instead of just:

              ExceptionHandlingQApplication app(argc,argv);
              

              The header / prototype for the ExceptionHandlingQApplication:

              class ExceptionHandlingQApplication : public QApplication
              {
                  Q_OBJECT
              public:
                  ExceptionHandlingQApplication(int& argc, char *argv[]);
                  virtual ~ExceptionHandlingQApplication();
                  virtual bool notify( QObject* receiver, QEvent* event);
              };
              

              And the constructor:

              ExceptionHandlingQApplication::ExceptionHandlingQApplication(int& argc, char *argv[])
                  : QApplication(argc, argv) {}
              

              I really don't see whats wrong with this?

              I've also tried:

              ExceptionHandlingQApplication app(argc, argv);
              

              Still causes a crash:
              406775cf-b10b-4f49-877f-3963d6b490b8-image.png

              Can anyone explain what is going on?

              Looking at another version of the almost the same source for another project I could see a difference, in one of the headers the definition:

              #define WIN32_LEAN_AND_MEAN 1
              

              I added this to the project I'm working on and tested again, now there is no error....I've no idea why this fixes it.

              Kind Regards,
              Sy

              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