LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cannot access memory at address? (https://www.linuxquestions.org/questions/linux-newbie-8/cannot-access-memory-at-address-4175556668/)

Shahid nx 10-20-2015 08:16 AM

Cannot access memory at address?
 
I observed a strange behaviour from gdb. Please assist me to identify this.
Below is affected snippet.
Note: Below for loop should not execute more than two times as max value of totNumEntries is 2.
Code:

totNumEntries = callLegPtr->activeSpContextPtr->directMediaPtr->numEntries;
for (index = 0; index < totNumEntries; index++)
{
.......
}

Printing values via gdb.
Code:


(gdb) p index
$79 = 35933
(gdb) p totNumEntries
$80 = 65535
(gdb) p callLegPtr->activeSpContextPtr->directMediaPtr->numEntries
Cannot access memory at address 0x53369955

As per gdb print, 0x53369955 is out of bond and cannot be accessible but still i can see "totNumEntries" having value 65535 because of that reason above for loop went into to many iterations (35933) and our process declared time out.
Type of totNumEntries is unsigned short (Max value is 65535).

My concern is what exactly the meaning of "Cannot access memory at address 0x53369955". When 0x53369955 is not accessible how come "totNumEntries" taking large value which maximum range for unsigned int type. It is very important for me to understand, please let me know if you need any further information.

Regards,
Shahid Hussain

rtmistler 10-20-2015 12:09 PM

You can print out the address and contents of callLegPtr, then do so for activeSpContextPtr, and once again for directMediaPtr. Something is wrong with one of those structures or pointers. 65535 is 0xFFFF, perhaps that came from somewhere if not nowhere. You can do a couple of things:
  1. Break before the assignment and check the structures in advance of the assignment
  2. Break down the assignment to steps. Make local variables to point to each of activeSpContext structure, directMedia structure, and then break before assignment and see each decode occur by stepping
  3. You may want to use -O0 to disable optimizations while you do this

jeremy 10-25-2015 04:05 AM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


All times are GMT -5. The time now is 02:54 AM.