Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QtWebEngineCore crash when calling std::exit()
Forum Updated to NodeBB v4.3 + New Features

QtWebEngineCore crash when calling std::exit()

Scheduled Pinned Locked Moved Unsolved QtWebEngine
4 Posts 3 Posters 714 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.
  • J Offline
    J Offline
    JW16
    wrote on last edited by
    #1

    In my sample program below, the call to exit() causes a crash with the following call stack:

    KernelBase.dll!00007ff898c8d862()	Unknown
    CoreMessaging.dll!Cn::FailFast::Do(struct _EXCEPTION_RECORD *,struct _CONTEXT *)	Unknown
    CoreMessaging.dll!Cn::FailFast::Do(struct _EXCEPTION_RECORD *)	Unknown
    CoreMessaging.dll!Cn::FailFast::IndexOutOfRange(void)	Unknown
    CoreMessaging.dll!Cn::Com::NativeEntry::NoContext_Prologue()	Unknown
    CoreMessaging.dll!Microsoft::CoreUI::IExportMessageSession$X__ExportAdapter::CloseEndpoint(struct Microsoft::CoreUI::HENDPOINT,enum Microsoft::CoreUI::CloseEndpointFlags$C::Values)	Unknown
    TextInputFramework.dll!00007ff883e45c0a()	Unknown
    TextInputFramework.dll!00007ff883e459a4()	Unknown
    TextInputFramework.dll!00007ff883e45894()	Unknown
    TextInputFramework.dll!00007ff883e7b540()	Unknown
    msctf.dll!00007ff89b0f5ba2()	Unknown
    msctf.dll!00007ff89b10aee0()	Unknown
    msctf.dll!00007ff89b101e97()	Unknown
    Qt5WebEngineCored.dll!Microsoft::WRL::ComPtr<IUnknown>::InternalRelease() Line 235	C++
    Qt5WebEngineCored.dll!Microsoft::WRL::ComPtr<IDXGIResource1>::~ComPtr<IDXGIResource1>() Line 291	C++
    Qt5WebEngineCored.dll!ui::`anonymous namespace'::TSFBridgeImpl::~TSFBridgeImpl() Line 171	C++
    [External Code]	
    Qt5WebEngineCored.dll!deleteUnicode(void * obj) Line 269	C++
    Qt5WebEngineCored.dll!`anonymous namespace'::OnThreadExitInternal(`anonymous-namespace'::TlsVectorEntry * tls_data) Line 310	C++
    Qt5WebEngineCored.dll!base::internal::PlatformThreadLocalStorage::OnThreadExit() Line 345	C++
    Qt5WebEngineCored.dll!OnThreadExit(void * module, unsigned long reason, void * reserved) Line 67	C++
    [External Code]	
    WebEngineCrash.exe!main(int argc, char * * argv) Line 15	C++
    WebEngineCrash.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 97	C++
    
    

    If I instead delete the app prior to calling exit(), there is no crash. Is there a way for me to completely shut down webengine and free associated resources before destructing the QApplication, so that I may call exit() before then? Or is this a Qt bug? Simply deleting the QWebView (and its page etc) prior to calling exit only seems to prevent the crash some of the time for this sample app, and doesn't seem to help at all in my real application.

    #include <QtWidgets>
    #include <QtWebEngineWidgets>
    
    int main( int argc, char *argv[] )
    {
        QApplication *app = new QApplication( argc, argv );
        QMainWindow *mw = new QMainWindow();
        QWebEngineView *wv = new QWebEngineView( mw );
        wv->setHtml( "<html><body>Some text</body>" );
        mw->setCentralWidget( wv );
        mw->show();
        int rc = app->exec();
    
        //delete app;
        exit( rc );
        delete app;
    
        return 0;
    }
    
    jsulmJ 1 Reply Last reply
    0
    • J JW16

      In my sample program below, the call to exit() causes a crash with the following call stack:

      KernelBase.dll!00007ff898c8d862()	Unknown
      CoreMessaging.dll!Cn::FailFast::Do(struct _EXCEPTION_RECORD *,struct _CONTEXT *)	Unknown
      CoreMessaging.dll!Cn::FailFast::Do(struct _EXCEPTION_RECORD *)	Unknown
      CoreMessaging.dll!Cn::FailFast::IndexOutOfRange(void)	Unknown
      CoreMessaging.dll!Cn::Com::NativeEntry::NoContext_Prologue()	Unknown
      CoreMessaging.dll!Microsoft::CoreUI::IExportMessageSession$X__ExportAdapter::CloseEndpoint(struct Microsoft::CoreUI::HENDPOINT,enum Microsoft::CoreUI::CloseEndpointFlags$C::Values)	Unknown
      TextInputFramework.dll!00007ff883e45c0a()	Unknown
      TextInputFramework.dll!00007ff883e459a4()	Unknown
      TextInputFramework.dll!00007ff883e45894()	Unknown
      TextInputFramework.dll!00007ff883e7b540()	Unknown
      msctf.dll!00007ff89b0f5ba2()	Unknown
      msctf.dll!00007ff89b10aee0()	Unknown
      msctf.dll!00007ff89b101e97()	Unknown
      Qt5WebEngineCored.dll!Microsoft::WRL::ComPtr<IUnknown>::InternalRelease() Line 235	C++
      Qt5WebEngineCored.dll!Microsoft::WRL::ComPtr<IDXGIResource1>::~ComPtr<IDXGIResource1>() Line 291	C++
      Qt5WebEngineCored.dll!ui::`anonymous namespace'::TSFBridgeImpl::~TSFBridgeImpl() Line 171	C++
      [External Code]	
      Qt5WebEngineCored.dll!deleteUnicode(void * obj) Line 269	C++
      Qt5WebEngineCored.dll!`anonymous namespace'::OnThreadExitInternal(`anonymous-namespace'::TlsVectorEntry * tls_data) Line 310	C++
      Qt5WebEngineCored.dll!base::internal::PlatformThreadLocalStorage::OnThreadExit() Line 345	C++
      Qt5WebEngineCored.dll!OnThreadExit(void * module, unsigned long reason, void * reserved) Line 67	C++
      [External Code]	
      WebEngineCrash.exe!main(int argc, char * * argv) Line 15	C++
      WebEngineCrash.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 97	C++
      
      

      If I instead delete the app prior to calling exit(), there is no crash. Is there a way for me to completely shut down webengine and free associated resources before destructing the QApplication, so that I may call exit() before then? Or is this a Qt bug? Simply deleting the QWebView (and its page etc) prior to calling exit only seems to prevent the crash some of the time for this sample app, and doesn't seem to help at all in my real application.

      #include <QtWidgets>
      #include <QtWebEngineWidgets>
      
      int main( int argc, char *argv[] )
      {
          QApplication *app = new QApplication( argc, argv );
          QMainWindow *mw = new QMainWindow();
          QWebEngineView *wv = new QWebEngineView( mw );
          wv->setHtml( "<html><body>Some text</body>" );
          mw->setCentralWidget( wv );
          mw->show();
          int rc = app->exec();
      
          //delete app;
          exit( rc );
          delete app;
      
          return 0;
      }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @JW16 Why do you allocate app on the heap? Simply allocate it on the stack. Also, why do you want to call exit? Simply return rc in your return statement in main() (which is currently unreachable due to exit()). And don't forget to delete other things you allocated on the heap.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      1
      • jsulmJ jsulm

        @JW16 Why do you allocate app on the heap? Simply allocate it on the stack. Also, why do you want to call exit? Simply return rc in your return statement in main() (which is currently unreachable due to exit()). And don't forget to delete other things you allocated on the heap.

        J Offline
        J Offline
        JW16
        wrote on last edited by
        #3

        @jsulm I am just allocating on the heap here for demonstration purposes with the explicit delete call. The problem remains if I allocate on the stack. The sample below has the same problem (change the closing brace to get crash/no crash). I understand exit() is pointless in this demo, but it is being called in the real application for reasons I won't get into here. I just want to know if there is a guaranteed way to completely shut down webengine prior to the app fully destructing.

        int main( int argc, char *argv[] )
        {
            int rc = 0;
            {
                QApplication app( argc, argv );
                QMainWindow mw;
                QWebEngineView *wv = new QWebEngineView( &mw );
                wv->setHtml( "<html><body>Some text</body>" );
                mw.setCentralWidget( wv );
                mw.show();
                rc = app.exec();
            //}
            exit( rc );
            }
        
            return 0;
        }
        
        JonBJ 1 Reply Last reply
        0
        • J JW16

          @jsulm I am just allocating on the heap here for demonstration purposes with the explicit delete call. The problem remains if I allocate on the stack. The sample below has the same problem (change the closing brace to get crash/no crash). I understand exit() is pointless in this demo, but it is being called in the real application for reasons I won't get into here. I just want to know if there is a guaranteed way to completely shut down webengine prior to the app fully destructing.

          int main( int argc, char *argv[] )
          {
              int rc = 0;
              {
                  QApplication app( argc, argv );
                  QMainWindow mw;
                  QWebEngineView *wv = new QWebEngineView( &mw );
                  wv->setHtml( "<html><body>Some text</body>" );
                  mw.setCentralWidget( wv );
                  mw.show();
                  rc = app.exec();
              //}
              exit( rc );
              }
          
              return 0;
          }
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @JW16
          I think you should add wv->close() before exiting, just in case that allows it to clean up better.

          Also does it still crash if you compile for release? If it only happens in debug you may end up chasing your tail.

          If I instead delete the app prior to calling exit(), there is no crash.

          Is that not a viable workaround if you find it is the only solution?

          1 Reply Last reply
          1

          • Login

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