Solved Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".
-
Hi,
1)Is there any way to know which or particularQVector
is poping this error .
2) I did run the debug of the project and it stopped after showing this error [debug images](https://ibb.co/FHLSVFy
https://ibb.co/VQ0m0q1)
3) It will be very helpful if you give some suggestion on how to check it faster.
4)at least can I able to know which the.cpp .h
is causing this error? -
where are you accessing those QVector<QVector> ? Can you show that code ?
-
@dheerendra many places inside the project, I will try to take the screenshots of them and upload.
-
If that is the it is too difficult to tell where you program has issue. This issue clearly indicates that you are trying to fetch the element from QVector with index(e.g 20) where 20 elements are not there.
-
Why are you saying the error comes from QVector? nothing in the error in the screenshot seems to indicate it.
That's an error from Visual C++ runtime library coming from a project that has MinGW in the folder path. This is dodgy!
What compiler and Qt kit are you using?
-
@VRonin I presume, because the console output from QtC says QVector<T> index out of range ;-)
@thippu
I would suggest building your application in debug mode and run it with the debugger attached. It will again crash but you should be able to step through the call stack backwards and find your exact point in your cpp code where you try to access a QVector outside it's actual range. -
@J.Hilk said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
I presume, because the console output from QtC says QVector<T> index out of range ;-)
Am I looking at the wrong screenshot? there's nothing of that sort in the link above
-
@VRonin the first one, that are 2 links to 2 different screenshots
-
I see now, thanks.
Unfortunately the stack trace doesn't point to anything at all... looks like the index out of range error happens in another thread. Can you use this to switch the stack view to other threads and see if one is stuck insideQVector
and post that trace? -
Hi
I wonder if there is a tread involved ?
The Mainwindow variable m. is called with start() which i find suspicious. -
@mrjj said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
I wonder if there is a tread involved ?
It most certainly is, as @VRonin said. The stack trace doesn't correspond to the tripped assertion.
-
As the last call in the trace is from main.cpp and that one does not contain any QVectors itself, from what I can see from the screenshot, the "crash" is most likly during exec call of QApplication -> most defenitly related to Thread-issues.
-
@J.Hilk said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
debugger attached
Hi, thanks for the reply, I did run the application in debug mode and attached the debugger to the current application by searching its name by going to Debug>Start Debugging> Attach to Running Application and did run the application in debugger mode and Run mode also again and again but nothing has shown on the Attached Debugger. Could you explain more on how
@J.Hilk said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
It will again crash but you should be able to step through the call stack backwards and find your exact point in your cpp code where you try to access a QVector outside it's actual range.
?
[screen shots](https://ibb.co/tCcXhDG
https://ibb.co/zVVsvrx) -
@mrjj Hi, Right now there is no thread and It was started like that initially but right now there are no threads created in the project.
@mrjj said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
The Mainwindow variable m. is called with start() which i find suspicious.
this starts the plotting component that's it. screen shot
-
@thippu said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
@J.Hilk said in Any faster way of checking which qvector is causing this error:" QVector::operator[]:"index out of range".:
It will again crash but you should be able to step through the call stack backwards and find your exact point in your cpp code where you try to access a QVector outside it's actual range.
?
took me a while to dig back up, but here's a step by step guide
https://forum.qt.io/topic/93371/invalid-parameter-passed-to-c-runtime/13
-
@J.Hilk , I found the place where it was causing the error,
It was fromsocket.cpp
, Initially I read 1540 bytes by looping and after that, I would like to have all theQVector
be zero
but I did code like thisseries.clear()
the declaration was like thisQVector<QVector<QPointF>> series
so, while another 1540 bytes have arrived through TCP socket and resulted in "index of range ",
Thank you so much, guys
@dheerendra , @VRonin , @J-Hilk , @mrjj , @kshegunov