Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. App crash during valgrind, on QProcess::start

App crash during valgrind, on QProcess::start

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
14 Posts 2 Posters 1.4k 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    Although my apps seems to run fine (on Fedora 34), I tried a valgrind to check for problems. Every time running in valgrind my app crashes on a syscall. Backtrace shows it is from QProcess::start. The parameters to the QProcess instance look fine. Can someone explain what is wrong and how I fix this?

    Program crashes on last line below.

    QProcess *command = new QProcess();
    QProcessEnvironment oldenvironment = QProcessEnvironment::systemEnvironment();
    command->setProcessEnvironment(oldenvironment);
    command->start(m_executableName, m_parameters);
    

    m_exectuableName is "which"
    m_parameters contains "dmidecode"

    sc1.jpg

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #13

      https://bugreports.qt.io/browse/QTBUG-82351

      ocgltdO 1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #2

        you need to show your code where qprocess starts.
        also try gdb to see if your app crashes at the same spot.

        1 Reply Last reply
        0
        • ocgltdO Offline
          ocgltdO Offline
          ocgltd
          wrote on last edited by ocgltd
          #3

          I added my code to the question. Yes it crashes in gdb too (when running WITH valgrind). But, in debug mode alone it does not crash, and from command line with gdb it does not crash.

          Is this a Fedora34 + valgrind issue? I've never encountered this type of problem before so unsure...

          JoeCFDJ 1 Reply Last reply
          0
          • ocgltdO ocgltd

            I added my code to the question. Yes it crashes in gdb too (when running WITH valgrind). But, in debug mode alone it does not crash, and from command line with gdb it does not crash.

            Is this a Fedora34 + valgrind issue? I've never encountered this type of problem before so unsure...

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #4

            @ocgltd valgrind runs very slow normally. Do you have any syn actions or updates or sort of multi-threading after process starts?

            ocgltdO 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @ocgltd valgrind runs very slow normally. Do you have any syn actions or updates or sort of multi-threading after process starts?

              ocgltdO Offline
              ocgltdO Offline
              ocgltd
              wrote on last edited by
              #5

              @JoeCFD I have other threads running, but this thread is blocked at the start method. Those other threads don't interact with this thread in any way....(not sure how to interpret your question)

              JoeCFDJ 1 Reply Last reply
              0
              • ocgltdO ocgltd

                @JoeCFD I have other threads running, but this thread is blocked at the start method. Those other threads don't interact with this thread in any way....(not sure how to interpret your question)

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #6

                @ocgltd not sure if the process needs any resources from somewhere else. If no, simply comment out this piece of code to run valgrind. The purpose of running valgrind is to find memory issues. If this process is a simple run and your code works fine, this part of the code will not cause any memory problem and you can simply ignore it.

                ocgltdO JoeCFDJ 2 Replies Last reply
                0
                • JoeCFDJ JoeCFD

                  @ocgltd not sure if the process needs any resources from somewhere else. If no, simply comment out this piece of code to run valgrind. The purpose of running valgrind is to find memory issues. If this process is a simple run and your code works fine, this part of the code will not cause any memory problem and you can simply ignore it.

                  ocgltdO Offline
                  ocgltdO Offline
                  ocgltd
                  wrote on last edited by
                  #7

                  @JoeCFD The data returned by this QProcess is actually important to the program. But I'll assume this is a valgrind + FC34 issue.

                  I'll try the same under Red Hat 7 in the near future and will update the thread.

                  ocgltdO 1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @ocgltd not sure if the process needs any resources from somewhere else. If no, simply comment out this piece of code to run valgrind. The purpose of running valgrind is to find memory issues. If this process is a simple run and your code works fine, this part of the code will not cause any memory problem and you can simply ignore it.

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by
                    #8

                    @JoeCFD
                    Another tool to check memory issue is asan. Add this to your cmake
                    set( CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize-recover=address -fsanitize=address" CACHE STRING "compile flags" FORCE )
                    try it out as well.

                    1 Reply Last reply
                    0
                    • JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by
                      #9

                      https://forum.qt.io/topic/16837/program-started-with-qprocess-results-in-segmentation-fault-works-fine-on-console/7

                      1 Reply Last reply
                      0
                      • ocgltdO ocgltd

                        @JoeCFD The data returned by this QProcess is actually important to the program. But I'll assume this is a valgrind + FC34 issue.

                        I'll try the same under Red Hat 7 in the near future and will update the thread.

                        ocgltdO Offline
                        ocgltdO Offline
                        ocgltd
                        wrote on last edited by
                        #10

                        @ocgltd I tried valgrind under Fedora 38 and the problem remains...

                        JoeCFDJ 1 Reply Last reply
                        0
                        • ocgltdO ocgltd

                          @ocgltd I tried valgrind under Fedora 38 and the problem remains...

                          JoeCFDJ Offline
                          JoeCFDJ Offline
                          JoeCFD
                          wrote on last edited by JoeCFD
                          #11

                          @ocgltd
                          in the link I posted above. There is something like:
                          today I tried to run my sender process with QProcess::startDetached() and it worked without any problems.
                          Try it out. If it works, simply change it back if you prefer the process to be attached after valgrind run.

                          I have a few processes running in my app and do not have this issue.

                          ocgltdO 1 Reply Last reply
                          0
                          • JoeCFDJ JoeCFD

                            @ocgltd
                            in the link I posted above. There is something like:
                            today I tried to run my sender process with QProcess::startDetached() and it worked without any problems.
                            Try it out. If it works, simply change it back if you prefer the process to be attached after valgrind run.

                            I have a few processes running in my app and do not have this issue.

                            ocgltdO Offline
                            ocgltdO Offline
                            ocgltd
                            wrote on last edited by ocgltd
                            #12

                            @JoeCFD I tried using startDetached and my app still crashed at the same point. However, it dumped the stdout of my process to the terminal window, following by html tag structured valgrind output.

                            Another clue, is that after crashing valgrind reports:

                            syscall param waitid(infop) points to unaddressable byte(s)
                            

                            on the QProcess.start line

                            1 Reply Last reply
                            0
                            • JoeCFDJ Offline
                              JoeCFDJ Offline
                              JoeCFD
                              wrote on last edited by
                              #13

                              https://bugreports.qt.io/browse/QTBUG-82351

                              ocgltdO 1 Reply Last reply
                              0
                              • JoeCFDJ JoeCFD

                                https://bugreports.qt.io/browse/QTBUG-82351

                                ocgltdO Offline
                                ocgltdO Offline
                                ocgltd
                                wrote on last edited by
                                #14

                                @JoeCFD Well that sure looks similar, so I'll chalk it up to a Qt bug for now. My app does lots of forking, so hard to temporarily disable this (to test for other leaks). So I'll just have to wait until this is fixed and recheck for leaks later.

                                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