C++ reasons for "read access violation", can overflowing double/int cause it

-2

I'm currently working on a plasma simulation and I'm running into the following error:read access violation

Exception thrown at 0x00AECD33 in GroundedBox.exe: 0xC0000005: Access violation reading location 0xFDFDFEB5.
Unhandled exception thrown: read access violation.
**this** was 0xFF0EFFC7.

The thing I don't understand is that the line producing the error(T operator() (int i) const { return d[i]; }) is working just fine. During the simulation first the world/area with the particles is initialized and then you enter a main loop where the particles are moved according to a specific time step size and all the fields are recalculated over and over until the total number of time steps is reached. And the whole loop can run multiple times without any issues, meaning there is no place where the index should run out of scope for any reason.

I also read What can cause segmentation faults in C++, but it didn't answer my question. (If you think the answer is in there, please be so kind explain it to help me out, before marking my question as already answered.)

I figured out that the amount of times the loop can run until the error occurs depends on the size of the time step, e.g. with a time step of 2*10^(-8)s the loop runs 3-4 times, with 2*10^(-9)s the loop runs about 30 times and with 2*10^(-10)s the loop runs about 290 times. This leads me to believe that there might be an issue with the solvers I used. But if something does diverge (which it shouldn't, because I did everything by the book and the time steps should be small enough), then I would expect to see some weird numbers in the results (like inf or some int jumping to a negative), but I looked at everything and the numbers seem fine.

Additionally there is no memory reaching its limits, since everything is done in place using pointers so the amount of data stored stays the same once initialized.

So are there other explanations which might cause the error and how can I check for those (my experience with C++ is still limited)? Is it possible that a double reaching inf or an int overflowing might cause this error?

(Note: Since the project is a little bigger and there is no minimal working example for this error, I didn't post the whole code so far. Just let me now if you need it and I will edit it into the question.)

c++
simulation
access-violation
plasma
asked on Stack Overflow Jan 31, 2021 by Silas • edited Feb 1, 2021 by Silas

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0