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

App crash during valgrind, on QProcess::start

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
14 Posts 2 Posters 1.5k 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.
  • O Offline
    O Offline
    ocgltd
    wrote on 22 Oct 2021, 17:16 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
    • J Offline
      J Offline
      JoeCFD
      wrote on 10 Aug 2022, 20:03 last edited by
      #13

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

      O 1 Reply Last reply 10 Aug 2022, 20:08
      0
      • J Offline
        J Offline
        JoeCFD
        wrote on 22 Oct 2021, 17:23 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
        • O Offline
          O Offline
          ocgltd
          wrote on 22 Oct 2021, 18:26 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...

          J 1 Reply Last reply 22 Oct 2021, 18:51
          0
          • O ocgltd
            22 Oct 2021, 18:26

            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...

            J Offline
            J Offline
            JoeCFD
            wrote on 22 Oct 2021, 18:51 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?

            O 1 Reply Last reply 22 Oct 2021, 18:53
            0
            • J JoeCFD
              22 Oct 2021, 18:51

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

              O Offline
              O Offline
              ocgltd
              wrote on 22 Oct 2021, 18:53 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)

              J 1 Reply Last reply 22 Oct 2021, 18:55
              0
              • O ocgltd
                22 Oct 2021, 18:53

                @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)

                J Offline
                J Offline
                JoeCFD
                wrote on 22 Oct 2021, 18:55 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.

                O J 2 Replies Last reply 22 Oct 2021, 19:01
                0
                • J JoeCFD
                  22 Oct 2021, 18:55

                  @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.

                  O Offline
                  O Offline
                  ocgltd
                  wrote on 22 Oct 2021, 19:01 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.

                  O 1 Reply Last reply 10 Aug 2022, 17:24
                  0
                  • J JoeCFD
                    22 Oct 2021, 18:55

                    @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.

                    J Offline
                    J Offline
                    JoeCFD
                    wrote on 22 Oct 2021, 19:02 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
                    • J Offline
                      J Offline
                      JoeCFD
                      wrote on 22 Oct 2021, 19:17 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
                      • O ocgltd
                        22 Oct 2021, 19:01

                        @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.

                        O Offline
                        O Offline
                        ocgltd
                        wrote on 10 Aug 2022, 17:24 last edited by
                        #10

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

                        J 1 Reply Last reply 10 Aug 2022, 17:49
                        0
                        • O ocgltd
                          10 Aug 2022, 17:24

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

                          J Offline
                          J Offline
                          JoeCFD
                          wrote on 10 Aug 2022, 17:49 last edited by JoeCFD 8 Oct 2022, 17:49
                          #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.

                          O 1 Reply Last reply 10 Aug 2022, 19:03
                          0
                          • J JoeCFD
                            10 Aug 2022, 17:49

                            @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.

                            O Offline
                            O Offline
                            ocgltd
                            wrote on 10 Aug 2022, 19:03 last edited by ocgltd 8 Oct 2022, 19:46
                            #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
                            • J Offline
                              J Offline
                              JoeCFD
                              wrote on 10 Aug 2022, 20:03 last edited by
                              #13

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

                              O 1 Reply Last reply 10 Aug 2022, 20:08
                              0
                              • J JoeCFD
                                10 Aug 2022, 20:03

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

                                O Offline
                                O Offline
                                ocgltd
                                wrote on 10 Aug 2022, 20:08 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