LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Yes, but in cases when you dynamically allocate an array or variable pointer, you don't always have this option.  You simply have to point to NULL.
0 Kudos
Message 11 of 20
(4,306 Views)

When I am dynamically allocating a buffer, I always initialize the pointer to NULL.

 

This tells me the pointer is not valid and I can use it to test if the buffer had been previously allocated before doing a call to free.

 

Like so:

 

double * buffer = NULL;

 

buffer = malloc (sizeof (double) * BUFFER_SIZE);

 

if (buffer != NULL) free (buffer);

 

 

 

Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 12 of 20
(4,305 Views)

The variable is declared as

 

             CMSG cmsg_tx[2047];      /* buffer for can messages */ 

 

 

How should I allocate is this case?

 

I do not understand the fact that a few elements (of index) past end of array but the value  of index at moment of error is 0 (0=0)....

0 Kudos
Message 13 of 20
(4,259 Views)

The described error does still appear sometimes. Is it possible that CVI has an error because of reporting out-of-bound while the index is set to zero? Maybe I can find my mistake if you can explain me what the meaning of the reportet error is. (Dereference of out-of-bound-pointer"

0 Kudos
Message 14 of 20
(3,952 Views)

Have you resove your problem about "out-of-bounds pointer"?I also encounter the same problem. Please share me how to deal with the problem

0 Kudos
Message 15 of 20
(3,771 Views)

No, sometimes the problem does still appear. I am not sure about the exact error source, but the problem does only appear in some routines. Maybe it is a grubby programming style at some program parts. - I do not know up to the present.

It would be nice if you can tell if you find something out.

0 Kudos
Message 16 of 20
(3,755 Views)
I had a relatively similar error. In one of our programs there is used a structure-type with variables and other structure-types inside, with variables and array-variables inside the inner structures, and arrays of structures of the inner structures. (How complicated 😐 ! But so the former programmers liked it! 😉 ) Let's have the following: A instance of th "main" structure-type (now called "abc") and a array of the inner structure (now called "fgh[3]") and a array-variable "arr[4]" inside the inner structure. And this "abc" is a pointer parameter of a function: "FunctionXYZ(TheStructureTypeOfABC *abc)". Inside of "FunctionXYZ" we accessed "arr[i]" from LabWindows 5.5 till 2012 by the following code: abc->fgh->arr[i] The implicit meaning of no index at "fgh" was that the compiler used the Index "0"-element. Now the 2013 compiler complains "Dereference of out-of-bounds pointer: 1 bytes (1 elements) past end of array." I changed the code the following: - A new temporary array "tmpArr[4]" was created. - I put the 4 values into "tmpArr[i]" (i=0,...3). - Finaly I made "memcpy(abc->fgh->arr, tmpArr, 4);" I think it would get the same result by putting all the 4 Values into "abc->fgh[0]->arr[i]". But I didn't checked that. Maybe that hint will help others to find the error not in the compiler-marked index-variable (here "arr") but in the (seamingly not marked) 'precursor'-variable(s) (here "fgh").
0 Kudos
Message 17 of 20
(3,320 Views)
Sorry ... all my carriage-returns of the input-field are gone in the web-presentation.
0 Kudos
Message 18 of 20
(3,319 Views)

I had similar problem.

 

Maybe this is where you make mistake.

 

For example if this is your callback function

 

int CVICALLBACK callback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
        switch (event)
        {
                 case EVENT_COMMIT:

 

                              int variable1, variable2;           // initialize variable. 

                              float variable 3, variable 4; 

                

                             function1...

                             function2....

                             break;
         }
         return 0;
}

 

You should put initialization variable above "switch (event)" and below "CVICALLBACK callback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)"

Like this:

 

int CVICALLBACK callback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{

         int variable1, variable2;           // initialize variable. 

         float variable 3, variable 4; 


        switch (event)
        {
                 case EVENT_COMMIT:

                

                             function1...

                             function2....

                             break;
         }
         return 0;
}

 

After this i dont get message error: ATAL RUN-TIME ERROR: Dereference of out-of-bounds pointer: 1388055715 bytes (86753482 elements) before start of array.

0 Kudos
Message 19 of 20
(3,006 Views)

I had similar problems in DEBUG configuration ONLY. CVI debugger gives (misleading?) "Dereference of out-of-bounds pointer" in situations where everything looks fine, or at least it's difficult to understand what the issue refers to.

So I had to disable "run-time check" in Debug build configuration to move on (Release build works fine).

I'm using now CVI 2017 so it looks like this issue remains for several versions.

 

Regards,

/Paolo Santos

0 Kudos
Message 20 of 20
(1,620 Views)