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. QT deployed executable crashes on some computers
Forum Update on Monday, May 27th 2025

QT deployed executable crashes on some computers

Scheduled Pinned Locked Moved Solved General and Desktop
42 Posts 9 Posters 9.7k 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.
  • JonBJ JonB

    @Lati
    Suggestion then is that your app does indeed attempt to load something off the network?

    Meanwhile, I don't understand why your program causes svchost.exe_TermService,.. svchost is to do with Windows Services, I wonder why these are involved in running this application?

    L Offline
    L Offline
    Lati
    wrote on last edited by Lati
    #17

    @JonB Yes, it loads a website from internet to a *QWebView * control (it is a small website with few kilobytes).

    App has nothing to do with Windows Services; at least nothing intentionally coded in the app which uses the Windows Services.

    1 Reply Last reply
    0
    • hskoglundH Online
      hskoglundH Online
      hskoglund
      wrote on last edited by
      #18

      Hmm error 0xc0000007b means there's a mixup of 32-bits and 64-bits .dlls. If your app is 32-bit, perhaps you've copied the msvc runtime library .dlls from C:\Windows\System32?
      Note that in Windows the 32-bits MSVC runtime .dlls are found in C:\Windows\SysWOW64 and instead C:\Windows\System32 houses the 64-bits one.

      JonBJ 1 Reply Last reply
      3
      • hskoglundH hskoglund

        Hmm error 0xc0000007b means there's a mixup of 32-bits and 64-bits .dlls. If your app is 32-bit, perhaps you've copied the msvc runtime library .dlls from C:\Windows\System32?
        Note that in Windows the 32-bits MSVC runtime .dlls are found in C:\Windows\SysWOW64 and instead C:\Windows\System32 houses the 64-bits one.

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

        @hskoglund
        I noted that too. But users says only happens when network cable unplugged! Normally he gets a 0xc0000008 rather than a 0xc0000007b . Strange how that could lead to 32-/64-bit issue?!

        L 1 Reply Last reply
        0
        • JonBJ JonB

          @hskoglund
          I noted that too. But users says only happens when network cable unplugged! Normally he gets a 0xc0000008 rather than a 0xc0000007b . Strange how that could lead to 32-/64-bit issue?!

          L Offline
          L Offline
          Lati
          wrote on last edited by
          #20

          @JonB No no, I haven't said it happens only when network cable is unplugged. It happens always with or without internet connection.

          @hskoglund I wonder if this is the reason because I use the same deployment on all computers. But, I will check that again.

          I hope I can solve this "mystery" soon :/

          JonBJ 1 Reply Last reply
          0
          • L Lati

            @JonB No no, I haven't said it happens only when network cable is unplugged. It happens always with or without internet connection.

            @hskoglund I wonder if this is the reason because I use the same deployment on all computers. But, I will check that again.

            I hope I can solve this "mystery" soon :/

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

            @Lati

            @JonB No no, I haven't said it happens only when network cable is unplugged. It happens always with or without internet connection.

            Read what you have posted and you do seem to say what I wrote. First earlier:

            Exception code: 0xc0000008

            then later screenshot

            0xc0000007b

            It's what you have pasted!

            Anyway, if you Google for the 0xc0000007b you will come across 32-/64-bit mis-match. I am not certain whether that always applies, but worth investigating.

            L 1 Reply Last reply
            1
            • JonBJ JonB

              @Lati

              @JonB No no, I haven't said it happens only when network cable is unplugged. It happens always with or without internet connection.

              Read what you have posted and you do seem to say what I wrote. First earlier:

              Exception code: 0xc0000008

              then later screenshot

              0xc0000007b

              It's what you have pasted!

              Anyway, if you Google for the 0xc0000007b you will come across 32-/64-bit mis-match. I am not certain whether that always applies, but worth investigating.

              L Offline
              L Offline
              Lati
              wrote on last edited by Lati
              #22

              @JonB @hskoglund
              Nope, I have re-deployed using windeployqt.exe and copied the necessary dlls from SysWOW64 (again) and still have the same problem.

              To summarize: I deployed the application created using QT Creator and test the executable on different computers. Deployed files are same on 6 different computers. Executable runs on three computers without any issue and crashes on other three without any indication.

              Additionally, I uninstalled all VC++ Runtime installations on one of the computer and installed the ones in the "C:\Qt\vcredist" and still have the same problem.

              1 Reply Last reply
              0
              • hskoglundH Online
                hskoglundH Online
                hskoglund
                wrote on last edited by
                #23

                If you have 2 computers pretty near each other, and one of them is of the crashing kind and the other is one the healthy ones, try swapping the network cables, i.e. unplug the network cable going to the healthy PC and instead plug it into the crashing PC, and the other way around.

                1 Reply Last reply
                0
                • fcarneyF Offline
                  fcarneyF Offline
                  fcarney
                  wrote on last edited by
                  #24

                  A couple thoughts:

                  • Make sure you are running the correct version of the deploy tool. I had issues with my deploys where I was running it under the 5.12.2 console when I should be running it under the 5.12.5 console.
                  • Check for race conditions on when your web data arrives. Is your app relying on the data it grabs and if it doesn't get it in time it will cause a crash.

                  C++ is a perfectly valid school of magic.

                  L 1 Reply Last reply
                  1
                  • fcarneyF fcarney

                    A couple thoughts:

                    • Make sure you are running the correct version of the deploy tool. I had issues with my deploys where I was running it under the 5.12.2 console when I should be running it under the 5.12.5 console.
                    • Check for race conditions on when your web data arrives. Is your app relying on the data it grabs and if it doesn't get it in time it will cause a crash.
                    L Offline
                    L Offline
                    Lati
                    wrote on last edited by Lati
                    #25

                    Ok. I decided to install the Qt on one of the computer where executable crashes. I copied the whole development folder and build the application. I can build the application in Debug and Release without any problem. However, when I try to start the debug with F5, I get following error:

                    Capture.PNG

                    Please note that Qt is installed on D drive. I tried few solutions offered by Google, like copying the Qt dll's in the debug folder which didn't help. I feel very desperate.

                    @hskoglund
                    Pc's are a bit far from each other :) I use remote desktop most of the time.

                    @fcarney
                    I checked that, it is v 5.12.1. I don't know how to be sure which version it should be.

                    L JonBJ 2 Replies Last reply
                    0
                    • L Lati

                      Ok. I decided to install the Qt on one of the computer where executable crashes. I copied the whole development folder and build the application. I can build the application in Debug and Release without any problem. However, when I try to start the debug with F5, I get following error:

                      Capture.PNG

                      Please note that Qt is installed on D drive. I tried few solutions offered by Google, like copying the Qt dll's in the debug folder which didn't help. I feel very desperate.

                      @hskoglund
                      Pc's are a bit far from each other :) I use remote desktop most of the time.

                      @fcarney
                      I checked that, it is v 5.12.1. I don't know how to be sure which version it should be.

                      L Offline
                      L Offline
                      Lati
                      wrote on last edited by Lati
                      #26

                      Finally! I found where the problem is. I received source code of the one of the libraries I use. And there is following code in the library:

                      programXRootDirectory = getenv("ProgramXROOT");
                      

                      And yes, if the environmental variable doesn't exist, executable crashes. Strangely, there is no sign about the crash caused by getenv.

                      I will keep this thread, maybe someone else has the same problem.

                      I would like to thank you everyone who tried to help me so far!

                      Update:getenv is deprecated and _dupenv_s recommended instead. More information about _dupenv_s

                      Pablo J. RoginaP 1 Reply Last reply
                      2
                      • L Lati

                        Finally! I found where the problem is. I received source code of the one of the libraries I use. And there is following code in the library:

                        programXRootDirectory = getenv("ProgramXROOT");
                        

                        And yes, if the environmental variable doesn't exist, executable crashes. Strangely, there is no sign about the crash caused by getenv.

                        I will keep this thread, maybe someone else has the same problem.

                        I would like to thank you everyone who tried to help me so far!

                        Update:getenv is deprecated and _dupenv_s recommended instead. More information about _dupenv_s

                        Pablo J. RoginaP Offline
                        Pablo J. RoginaP Offline
                        Pablo J. Rogina
                        wrote on last edited by
                        #27

                        @Lati said in QT deployed executable crashes on some computers:

                        Strangely, there is no sign about the crash caused by getenv.

                        Well, it looks like the culprit isn't getenv() but the way the return value from that function is used within the DLL later on. From man getvenv:

                        The getenv() function returns a pointer to the value in the environment, or NULL if there is no match.

                        so programXRootDirectory becomes NULL when the variable is not set, and the world ends...

                        Upvote the answer(s) that helped you solve the issue
                        Use "Topic Tools" button to mark your post as Solved
                        Add screenshots via postimage.org
                        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                        L 1 Reply Last reply
                        3
                        • L Lati

                          Ok. I decided to install the Qt on one of the computer where executable crashes. I copied the whole development folder and build the application. I can build the application in Debug and Release without any problem. However, when I try to start the debug with F5, I get following error:

                          Capture.PNG

                          Please note that Qt is installed on D drive. I tried few solutions offered by Google, like copying the Qt dll's in the debug folder which didn't help. I feel very desperate.

                          @hskoglund
                          Pc's are a bit far from each other :) I use remote desktop most of the time.

                          @fcarney
                          I checked that, it is v 5.12.1. I don't know how to be sure which version it should be.

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

                          @Lati
                          That file error screenshot is in Qt5Cored.dll. Note the d at the end of the name. That is the version compiled for debug (plus the message). Why are you deploying debug DLLs?

                          It would be interesting to see whether the problem across different PCs even occurs any more if you compiled & released for Release instead?

                          getenv does not crash when an environment variable does not exist, it returns NULL. If the code fails to deal with that (e.g. dereferences), that's a different matter, and is the only way it could "crash". So you have verified that the environment variable named ProgramXROOT does not/does exist on the machines which crash/don't crash respectively?

                          1 Reply Last reply
                          1
                          • Pablo J. RoginaP Pablo J. Rogina

                            @Lati said in QT deployed executable crashes on some computers:

                            Strangely, there is no sign about the crash caused by getenv.

                            Well, it looks like the culprit isn't getenv() but the way the return value from that function is used within the DLL later on. From man getvenv:

                            The getenv() function returns a pointer to the value in the environment, or NULL if there is no match.

                            so programXRootDirectory becomes NULL when the variable is not set, and the world ends...

                            L Offline
                            L Offline
                            Lati
                            wrote on last edited by Lati
                            #29

                            @Pablo-J-Rogina
                            Exactly! No-one would guess the crash is due to getenvsince all indications were showing that it was either false libraries or graphic card issue.

                            @JonB
                            I am not deploying anything on that screen. The screenshot is after I clicked on F5 to debug the code and the path of the Qt5Cored.dll is from Qt's installation directory (Qt is installed on D: drive, as I mentioned). getenv crashes on my computer, as well as the deployed executable crashes on the computers if the environmental variable doesn't exist. It is very easy to test by writing a small application.

                            JonBJ 1 Reply Last reply
                            0
                            • L Lati

                              @Pablo-J-Rogina
                              Exactly! No-one would guess the crash is due to getenvsince all indications were showing that it was either false libraries or graphic card issue.

                              @JonB
                              I am not deploying anything on that screen. The screenshot is after I clicked on F5 to debug the code and the path of the Qt5Cored.dll is from Qt's installation directory (Qt is installed on D: drive, as I mentioned). getenv crashes on my computer, as well as the deployed executable crashes on the computers if the environmental variable doesn't exist. It is very easy to test by writing a small application.

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

                              @Lati said in QT deployed executable crashes on some computers:

                              It is very easy to test by writing a small application.

                              char *p = getenv("ProgramXROOT");
                              // or
                              char *p = getenv("AnythingElseWhichDoesntExist");
                              

                              won't crash. It will set p to NULL/nullptr.

                              If the program continues and does not check for that, assuming that p will not be null, it may crash. That is all @Pablo-J-Rogina and I are saying.

                              Pablo J. RoginaP 1 Reply Last reply
                              0
                              • fcarneyF Offline
                                fcarneyF Offline
                                fcarney
                                wrote on last edited by
                                #31

                                @Lati said in QT deployed executable crashes on some computers:

                                programXRootDirectory

                                It would be interesting to know what the data type is for this variable. I could not get QString to crash or misbehave.

                                {
                                        char* null = nullptr;
                                
                                        QString test = "hallo";
                                        qInfo() << "before init null";
                                        test = QString(null);
                                        qInfo() << test;
                                        qInfo() << "after init null";
                                
                                        QString test2 = "hallo again";
                                        qInfo() << "before assign null";
                                        test2 = null;
                                        qInfo() << test2;
                                        qInfo() << "after assign null";
                                    }
                                

                                C++ is a perfectly valid school of magic.

                                L 1 Reply Last reply
                                0
                                • fcarneyF fcarney

                                  @Lati said in QT deployed executable crashes on some computers:

                                  programXRootDirectory

                                  It would be interesting to know what the data type is for this variable. I could not get QString to crash or misbehave.

                                  {
                                          char* null = nullptr;
                                  
                                          QString test = "hallo";
                                          qInfo() << "before init null";
                                          test = QString(null);
                                          qInfo() << test;
                                          qInfo() << "after init null";
                                  
                                          QString test2 = "hallo again";
                                          qInfo() << "before assign null";
                                          test2 = null;
                                          qInfo() << test2;
                                          qInfo() << "after assign null";
                                      }
                                  
                                  L Offline
                                  L Offline
                                  Lati
                                  wrote on last edited by Lati
                                  #32

                                  @fcarney
                                  You can reproduce the issue with the following example (at least it crashes on my computer:)):

                                  main.cpp

                                  #include "mainwindow.h"
                                  #include <QApplication>
                                  
                                  int main(int argc, char *argv[])
                                  {
                                      QApplication a(argc, argv);
                                      MainWindow w;
                                      w.show();
                                      return a.exec();
                                  }
                                  

                                  mainWindow.h:

                                  #ifndef MAINWINDOW_H
                                  #define MAINWINDOW_H
                                  
                                  #include <QMainWindow>
                                  
                                  QT_BEGIN_NAMESPACE
                                  namespace Ui { class MainWindow; }
                                  QT_END_NAMESPACE
                                  
                                  class MainWindow : public QMainWindow
                                  {
                                      Q_OBJECT
                                  
                                  public:
                                      MainWindow(QWidget *parent = nullptr);
                                      ~MainWindow();
                                  
                                      // Senex root directory
                                      std::string notExistEnvVar;
                                  
                                  private:
                                      Ui::MainWindow *ui;
                                  };
                                  #endif // MAINWINDOW_H
                                  

                                  mainWindow.cpp

                                  #include "mainwindow.h"
                                  #include "ui_mainwindow.h"
                                  
                                  MainWindow::MainWindow(QWidget *parent)
                                      : QMainWindow(parent)
                                      , ui(new Ui::MainWindow)
                                  {
                                      ui->setupUi(this);
                                  
                                      notExistEnvVar = getenv("notExistEnvVar");
                                  }
                                  
                                  MainWindow::~MainWindow()
                                  {
                                      delete ui;
                                  }
                                  

                                  Compiled with MSVC2015 64bit.

                                  1 Reply Last reply
                                  0
                                  • fcarneyF Offline
                                    fcarneyF Offline
                                    fcarney
                                    wrote on last edited by fcarney
                                    #33

                                    You are getting an exception because you are assigning nullptr to std::string. Assign to

                                    char* ptr = getenv("notExistEnvVar");
                                    if(ptr != nullptr)
                                      notExistEnvVar = ptr;
                                    

                                    getenv is not crashing

                                    Edit:
                                    or use QString

                                    QString str = getenv("notExistEnvVar");
                                    

                                    C++ is a perfectly valid school of magic.

                                    JonBJ L 2 Replies Last reply
                                    2
                                    • fcarneyF fcarney

                                      You are getting an exception because you are assigning nullptr to std::string. Assign to

                                      char* ptr = getenv("notExistEnvVar");
                                      if(ptr != nullptr)
                                        notExistEnvVar = ptr;
                                      

                                      getenv is not crashing

                                      Edit:
                                      or use QString

                                      QString str = getenv("notExistEnvVar");
                                      
                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on last edited by
                                      #34

                                      @fcarney Thank you :)

                                      1 Reply Last reply
                                      1
                                      • JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #35

                                        For std::string s = nullptr, see https://stackoverflow.com/questions/10771864/assign-a-nullptr-to-a-stdstring-is-safe/10771938. Accepted answer:

                                        Requires: s shall not be a null pointer.

                                        Since the standard does not ask the library to throw an exception when this particular requirement is not met, it would appear that passing a null pointer provoked undefined behavior.

                                        1 Reply Last reply
                                        2
                                        • fcarneyF Offline
                                          fcarneyF Offline
                                          fcarney
                                          wrote on last edited by
                                          #36

                                          @JonB said in QT deployed executable crashes on some computers:

                                          undefined

                                          !!!UNDEFINED!!!
                                          The end is nigh!

                                          Good find!

                                          C++ is a perfectly valid school of magic.

                                          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