LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

Hello,

 

I have the problem that in my CAN - Application the following error appears: Dereference of out-of-bounds pointer

 

The debugger marks the following variable in this text line: if (cmsg_rx[i].id > 384 && cmsg_rx[i].id < 640 && cmsg_rx[i].len <= 8)

 

This error does not appear always, only sometimes but then in series when trying to run the program. Later, I can start and exit the program without problems.

 

In one file, the array is defined as CMSG cmsg_rx[2047]; and in the function where the error appeares as extern CMSG cmsg_rx[];

 

How can I avoid this error?

0 Kudos
Message 1 of 19
(3,663 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

When the debugger breaks program execution, examine the value of <i> index: since the error is "xx bytes before start of array" you are very likely to have i < 0, which is illegal. It appears as under some conditions your program does not initializes that variable at the correct value, you should investigate on this.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 19
(3,649 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

Thank you for having a look on my problem. I prooved the index but i=0. So the problem is not the value of index, or did I misunderstand you?
0 Kudos
Message 3 of 19
(3,644 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

This is strange: 0 is a valid value for an array index, you should not get this error with such an index.

Are you sure you have this index value when you get the error?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 19
(3,626 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

When running the program in debug configuration, the program breaks at this error. Then I move the mouse to the index of turquoise marked array and i=0 is displayed. So I think that i=0 when the error occurs, correct? The error does not appear in release configuration.
0 Kudos
Message 5 of 19
(3,623 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

Hi chemph,

 

could you post a small example to reproduce this error on my side?

 

Regards,

Andreas S
Systems Engineer
0 Kudos
Message 6 of 19
(3,594 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

Now, I have new findings in my problem. Because of wondering about the fact thar error only appears ins debug configuration, I deleted the file projectname_dbg.cdb and the directory cvibuild.projectname. From this point on, I can execute the program in debug mode a few times then the error appears again. I do not really understand this. Is it possible that the error is evocated by CVI?

 

I can shorten my program to the minimum and post the code which makes the error.

 

Thank you very much for helping me!

0 Kudos
Message 7 of 19
(3,562 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

When you delete those elements, you force the compile to rebuild the debug executable from the source code, whereas if you simply re-run a project in the IDE without modifying anything actual debug executable is used as is. This should be the same as using Build >> Mark project for recompilation menu option.

 

It is not clear to me why the program runs a few time without -apparently- any modification before the error starts rising: looking at your code could help to find a reason and a solution, if you can narrow down it to a subset that still offers this erratic condition.

 

One last question: is the byte count in error message always the same of it varies randomly? In the first case I would be prone to look for some repetitive condition that generates the error while in the second I'd start by lookong for some unizialized index or something similar to this.

Message Edited by Roberto Bozzolo on 02-04-2010 02:40 PM


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 19
(3,559 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.


Roberto Bozzolo wrote:

When you delete those elements, you force the compile to rebuild the debug executable from the source code, whereas if you simply re-run a project in the IDE without modifying anything actual debug executable is used as is. This should be the same as using Build >> Mark project for recompilation menu option.

 

It is not clear to me why the program runs a few time without -apparently- any modification before the error starts rising: looking at your code could help to find a reason and a solution, if you can narrow down it to a subset that still offers this erratic condition.

 

One last question: is the byte count in error message always the same of it varies randomly? In the first case I would be prone to look for some repetitive condition that generates the error while in the second I'd start by lookong for some unizialized index or something similar to this.

Message Edited by Roberto Bozzolo on 02-04-2010 02:40 PM

I ran into this problem too and was pulling my hair out.  Recompiling everything seems to have worked.

0 Kudos
Message 9 of 19
(3,381 Views)

Re: FATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

To me this appears to be a classic example of an uninitialized variable. I know you say you have the index variable initialized but I can't think of anything else that would result in this error.

 

I personally have a policy of initializing EVERYTHING when I declare it, even if I know I am going to initialize it programmatically right away.

 

You will never see me write something like:

int i;

it will always be:

int i = 0;

Starting from a known state is invaluable. I cannot tell you how much trouble I had finding initialization problems prior to adopting that practice. It is a very good habit to get into and can save you a lot of hair pulling.

 

I also highly recommend enabling the following build options:

Detect uninitialized local variables at run-time

Detect unreachable code

Detect unreferenced identifiers

 

Set Uninitialized local variable detection to Agressive

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 10 of 19
(3,276 Views)