Invalid parameter passed to c runtime

  • How could i find the line of code, or function causing these problems? Please don't paste me any junky articles from MS, documentations, etc, they don't explain it well, especially if i get it first time.

    Is there any way of doing it? Debugger can't find them, and i get a lot of code there, i got some of them i fix it, but after adding new code, the errors are back, and i don't have time to lose 8h for debugging stuff, and 30min for programming.

    Someone could help? How to find the line or function, causing it?

  • Qt Champions 2017

    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.


  • 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] );

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

  • @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] );

  • Qt Champions 2017

    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.

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

  • 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 Champions 2017

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

  • @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:

    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.

  • No body knows, how to do that?

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

    Good luck.

  • @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:


    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

    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:


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

  • Qt Champions 2017

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

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.