Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Invalid parameter passed to c runtime

    General and Desktop
    8
    16
    7492
    Loading More Posts
    • 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.
    • aha_1980
      aha_1980 Lifetime Qt Champion @UnLuckyGuy last edited by

      HI @UnLuckyGuy,

      does your program crash? If yes, then start it in the debugger, it will stop the program at the crash point. Then you can inspect the stack trace to see from where in your program the error originates.

      Otherwise: Can you show us the places you already fixed your code? Maybe we can see a pattern.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply Reply Quote 1
      • U
        UnLuckyGuy last edited by UnLuckyGuy

        Ofc it crash, QT 5.20 doesn't show anything in debug mode, 5.60, will stop on some weird code, i think they are some dll's, it will not stop on any of "readable" code i just created, weird stuff from ntdll or something like this. THe best thing is, my program crashed in another situation, 5 times in a row, when i was doing the same action (button click), and then, it stops, no more crashes at that situation, idk if it's because i moved it from 5.20, but i am mad at it.

        Anyways, i want the code, what kind of code cause it.
        I am not gonna paste any code, because it's simple.
        Most the time, they are neasted for loops, so:

        for(int i = 0; i < SOMTHING; i++)
        {
        for(int j = another_parameter; j < SOMETHING_ELSE; j++)
        {
        new_string.append( old_strings[i][j] );
        }
        }
        
        1 Reply Last reply Reply Quote 0
        • Christian Ehrlicher
          Christian Ehrlicher Lifetime Qt Champion last edited by

          So you should check if old_strings[][] is large enough to avoid out-of-bounds access.

          Qt has to stay free or it will die.

          U 1 Reply Last reply Reply Quote 3
          • U
            UnLuckyGuy @Christian Ehrlicher last edited by UnLuckyGuy

            @Christian-Ehrlicher I did it already, it was just an example. What i do:

            for(int i = 0; i < SOMTHING; i++)
            {
            for(int j = another_parameter; j < old_strings[i].count(); j++)
            {
            new_string.append( old_strings[i][j] );
            }
            }
            
            1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators @UnLuckyGuy last edited by

              i don't have time to lose 8h for debugging stuff, and 30min for programming.

              Perhaps you should consider another job in that case, because this is not at all uncommon.

              Read and abide by the Qt Code of Conduct

              U 1 Reply Last reply Reply Quote 7
              • U
                UnLuckyGuy @kshegunov last edited by

                @kshegunov Who told u i am gonna work as a programmer?

                kshegunov 1 Reply Last reply Reply Quote -2
                • Christian Ehrlicher
                  Christian Ehrlicher Lifetime Qt Champion last edited by

                  Still no check if old_strings[i] goes out-of-bounds. But using a debugger here will definitively help as it can you your the values of i,j and (if it's not a plain c array) old_strings.

                  Qt has to stay free or it will die.

                  1 Reply Last reply Reply Quote 1
                  • kshegunov
                    kshegunov Moderators @UnLuckyGuy last edited by kshegunov

                    @UnLuckyGuy said in Invalid parameter passed to c runtime:

                    Who told u i am gonna work as a programmer?

                    With this demeanor I'm not quite sure you're going to work at all, but that's beside the point. Without enough and complete information no problem can be diagnosed or fixed.
                    You have denied to show us the relevant parts of the code, what variable types are the suspects involved, the stack trace - those winnt dll calls originate somewhere, they don't just fall out of the sky, and last but (probably) not least you have acted as we, the users of this forum, owe you our time.
                    Just to make sure that last one rings: we don't owe you, neither time, nor code, nor anything else, so don't try to act as if we do; it doesn't sit well and it doesn't help your case. We try to help other people on our own (free) time and we are not paid for it so as to feel obliged to indulge you.

                    Read and abide by the Qt Code of Conduct

                    U 1 Reply Last reply Reply Quote 8
                    • U
                      UnLuckyGuy @kshegunov last edited by UnLuckyGuy

                      @kshegunov I am looking for any technique, to find those errors, that's it. I don't wanna show anything, because it's not my point.

                      I found something like this: https://msdn.microsoft.com/en-us/library/a9yf33zb.aspx

                      Idk how to use those methods, that's why i create this topic for future, if it will happened, i will know how to find them, not to fix this particular one by showing a lot of code, and after few days it could happened again.

                      1 Reply Last reply Reply Quote 0
                      • U
                        UnLuckyGuy last edited by

                        No body knows, how to do that?

                        K J.Hilk 2 Replies Last reply Reply Quote 0
                        • K
                          kenchan @UnLuckyGuy last edited by

                          @UnLuckyGuy
                          Hi, this seems to be a very hard one to debug. Do you know about these links? If not I hope they will be of some help.

                          https://stackoverflow.com/questions/36968475/how-to-debug-invalid-parameter-passed-to-c-runtime-function
                          http://dennisyurichev.blogspot.com/2013/05/warning-invalid-parameter-passed-to-c.html

                          Good luck.

                          1 Reply Last reply Reply Quote 1
                          • J.Hilk
                            J.Hilk Moderators @UnLuckyGuy last edited by J.Hilk

                            @UnLuckyGuy
                            you still haven't told us jet, what the stack trace is telling you.

                            You only wrote:

                            "readable" code i just created, weird stuff from ntdll or something like this

                            that's fine, sometimes, especially if you call system or other external libaries, the debugger can stop in the Disassembler or plain old hex text. You can go back in the call list, until you reach your own 'clean text' code.

                            take for example this crash:

                            0_1533881781942_7207a3e7-df0e-43c3-861e-56b121f5db9c-image.png

                            on the first glance meaningless, but going back you a can see a QVector operation was called, bottom part of the image.

                            going back in the list
                            0_1533881927736_28224422-f87c-4ced-9da2-8e4bf4a8a067-image.png

                            this tells us, a Qvector was tried to be accessed outside its boundaries. Still doesn't say much, a program can have millions of QVectors.

                            going back one more:

                            0_1533882006188_b826408e-6e47-4b5e-919d-59deaa82fe55-image.png

                            and there is the culprit. Doesn't matter much, if you don't use QtCreator, nearly all IDE's have a similar system.

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

                            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

                            aha_1980 JonB 2 Replies Last reply Reply Quote 7
                            • aha_1980
                              aha_1980 Lifetime Qt Champion @J.Hilk last edited by

                              @J.Hilk Thanks for that very nice explanation :) Should be in a FAQ entry, IMHO.

                              Qt has to stay free or it will die.

                              1 Reply Last reply Reply Quote 4
                              • JonB
                                JonB @J.Hilk last edited by

                                @J.Hilk
                                Unfortunately the OP has told us "he doesn't want to waste his time debugging", he just wants the solution. ;-)

                                1 Reply Last reply Reply Quote 3
                                • Padawan
                                  Padawan last edited by

                                  Haha, Funny thread
                                  @J-Hilk thanks for the explanation you gave up there about debugging. It taught me something new

                                  Ningen

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post