Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Errors logged in rmat file: (7 Items)
   
Errors logged in rmat file  
I have been getting a lot of errors in my rmat file.  I think this is the reason I cannot use the "get leaks" feature of
 the memory analysis tool.  Can someone help me figure out what I can do to resolve these errors please?

EV={433369,2,1,0xd1976cba,ERR,249704530, merrno=6,loc={fn=delete_arr,bt={0xbabfa084,0xbabf8cb2,0xbaaa2aa5,0xbaaa08a8,
0xba9e6d1a}},dh={uptr=0x3a129f98,fn=new_arr,sz=24,usz=21,id=0x7b127b7,flag={use}}}
E
EV={433370,2,1,0xd19acbe1,ERR,249704530, merrno=6,loc={fn=free,bt={0xb9c54148,0xb97a4e97,0xb97a2bce,0xb97a32e3,
0xb97a344e}},dh={uptr=0x32276fa0,fn=malloc,sz=16,usz=12,id=0x7b945be,flag={use}}}
E
EV={433371,2,1,0xd19afea7,ERR,249704530, merrno=6,loc={fn=delete,bt={0xb88c7039,0xb88ce5f2,0xb86720ec,0xb867861f,
0xb86786c4}},dh={uptr=0x32276fa0,fn=new,sz=16,usz=16,id=0x7b991cb,flag={use}}}
E
EV={433372,2,1,0xd19b1de6,ERR,249704530, merrno=6,loc={fn=delete_arr,bt={0xb82d08ed,0xb8895d04,0xb8896361,0xb85be45c,
0xb8608774}},dh={uptr=0x32276fa0,fn=new_arr,sz=16,usz=16,id=0x7b991d6,flag={use}}}
E
EV={433373,2,1,0xd19b316d,ERR,249704530, merrno=6,loc={fn=delete,bt={0xb88c7039,0xb88ce5f2,0xb86720ec,0xb867861f,
0xb86786c4}},dh={uptr=0x32276fa0,fn=new,sz=16,usz=16,id=0x7b992f6,flag={use}}}
E
EV={433374,2,1,0xd19b44f4,ERR,249704530, merrno=6,loc={fn=delete_arr,bt={0xb82d08ed,0xb8895d04,0xb8896361,0xb85be45c,
0xb8608774}},dh={uptr=0x32276fa0,fn=new_arr,sz=16,usz=16,id=0x7b99303,flag={use}}}
E
Re: Errors logged in rmat file  
You have to load this file in IDE using Import command. And open Errors 
tab of loaded session - you will see readable version with full backtrace.
Rex Lam wrote:
> I have been getting a lot of errors in my rmat file.  I think this is the reason I cannot use the "get leaks" feature 
of the memory analysis tool.  Can someone help me figure out what I can do to resolve these errors please?
>
> EV={433369,2,1,0xd1976cba,ERR,249704530, merrno=6,loc={fn=delete_arr,bt={0xbabfa084,0xbabf8cb2,0xbaaa2aa5,0xbaaa08a8,
0xba9e6d1a}},dh={uptr=0x3a129f98,fn=new_arr,sz=24,usz=21,id=0x7b127b7,flag={use}}}
> E
> EV={433370,2,1,0xd19acbe1,ERR,249704530, merrno=6,loc={fn=free,bt={0xb9c54148,0xb97a4e97,0xb97a2bce,0xb97a32e3,
0xb97a344e}},dh={uptr=0x32276fa0,fn=malloc,sz=16,usz=12,id=0x7b945be,flag={use}}}
> E
> EV={433371,2,1,0xd19afea7,ERR,249704530, merrno=6,loc={fn=delete,bt={0xb88c7039,0xb88ce5f2,0xb86720ec,0xb867861f,
0xb86786c4}},dh={uptr=0x32276fa0,fn=new,sz=16,usz=16,id=0x7b991cb,flag={use}}}
> E
> EV={433372,2,1,0xd19b1de6,ERR,249704530, merrno=6,loc={fn=delete_arr,bt={0xb82d08ed,0xb8895d04,0xb8896361,0xb85be45c,
0xb8608774}},dh={uptr=0x32276fa0,fn=new_arr,sz=16,usz=16,id=0x7b991d6,flag={use}}}
> E
> EV={433373,2,1,0xd19b316d,ERR,249704530, merrno=6,loc={fn=delete,bt={0xb88c7039,0xb88ce5f2,0xb86720ec,0xb867861f,
0xb86786c4}},dh={uptr=0x32276fa0,fn=new,sz=16,usz=16,id=0x7b992f6,flag={use}}}
> E
> EV={433374,2,1,0xd19b44f4,ERR,249704530, merrno=6,loc={fn=delete_arr,bt={0xb82d08ed,0xb8895d04,0xb8896361,0xb85be45c,
0xb8608774}},dh={uptr=0x32276fa0,fn=new_arr,sz=16,usz=16,id=0x7b99303,flag={use}}}
> E
>
>
>
>
> _______________________________________________
>
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post38027
>
>   
Re: Errors logged in rmat file  
Thank you for the suggestion.  It appears most of the errors I am getting are:
"data has been written outside allocated memory block"

How does the memory analysis tool detect this error (what does this error mean)?  I could see 5 lines of backtrace with 
each error event.  Some of the backtraces make sense and some do not.  Of the ones that make sense, I could not see any 
problems.  I would like to know what to look for in code that could cause this error event to be logged.  The backtrace 
is for "FULL TRACE", which I assume is the backtrace of the deallocation.  There is no backtrace for "FULL ALLOC TRACE".


Rex
Re: Errors logged in rmat file  
Ok full trace does not actually mean full, poor wording. It is a partial backtrace but bigger that 1 line. Because it 
costs a lot to store it, by default it only stores 5 items for error and 5 for allocation itself. There are options to 
increase it (Memory Analysis tab options in launch configurations or env variables if you running from command line, I 
don't remember exact names, they should be documented).

About memory written out of bounds.
So this error is tricky. This is pretty much buffer overflow or underflow. Depends on memory layout it can be harmless 
or really bad. The problem is that backtrace tool prints it at the time error is detected, not when it happens. For 
example you do something like this:

x = malloc(1);
x[1]= 3;
...
free(x);

You writing to a second byte, while you only allocated one. However at line 2 where it
happens tool has no meaning to detect it (because MAT is not doing instrumentation of code). However when memory is 
freed it can be detected because for example garbage data appears at the end of the block or internal links are 
corrupted. In this case trace would show "free" call. In this case you have to manually inspect places where memory can 
be overriden. In worst case it is not even same memory which is allocated is being manipulated, for example if you 
allocate 2 blocks side by side and "underwrite" to second one, the corrupted one would be first block - which does not 
seems to be related at all to  the code.


And about leaks (original problem) did you try to insert leaks probs directly in the code?
Re: Errors logged in rmat file  
Elena,

Thank you for the explanation.  It was very helpful.  I have not used the list leaks function in code yet.  It has 
become a lower priority because the big leaks have been resolved already.  There appears to be random memory corruption 
so we are looking into memory errors.

There are some backtraces that do not make sense to me.  Here is an example:
PresentationManager at startup,9/28/09 5:17 PM,7782,424101103,614826065,3,1,data has been written outside allocated 
memory block,0xb943f70,delete_arr,new,2,1,<no source code>,<no source code>,"
[0xb84d2d8f] <no source code>
[0xb84d2f52] <no source code>
[0xb90e1a61] <no source code>
[0xb55fd97] <no source code>
[0xb91206db] <no source code>
",,

The fourth address in the back trace is an address in the heap.  I don't understand how the return address could be in 
heap memory.  I decoded these addresses but the succession of calls do not make sense either.  Can the backtrace contain
 an address on the heap?

Rex
Re: Errors logged in rmat file  
This can happened either is stack is corrupted (classic stack buffer 
overflow) or backtrace functionality is fulled some-how and cannot 
restore proper stack.
Try to use not-optimized code -O0 and without inline function 
-fno-inline-functions (or something like that)

But why do you think it is heap address? They all look shared library 
addresses with unresolved libraries

Rex Lam wrote:
> Elena,
>
> Thank you for the explanation.  It was very helpful.  I have not used the list leaks function in code yet.  It has 
become a lower priority because the big leaks have been resolved already.  There appears to be random memory corruption 
so we are looking into memory errors.
>
> There are some backtraces that do not make sense to me.  Here is an example:
> PresentationManager at startup,9/28/09 5:17 PM,7782,424101103,614826065,3,1,data has been written outside allocated 
memory block,0xb943f70,delete_arr,new,2,1,<no source code>,<no source code>,"
> [0xb84d2d8f] <no source code>
> [0xb84d2f52] <no source code>
> [0xb90e1a61] <no source code>
> [0xb55fd97] <no source code>
> [0xb91206db] <no source code>
> ",,
>
> The fourth address in the back trace is an address in the heap.  I don't understand how the return address could be in
 heap memory.  I decoded these addresses but the succession of calls do not make sense either.  Can the backtrace 
contain an address on the heap?
>
> Rex
>
>
>
> _______________________________________________
>
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post39216
>
>   
Re: Errors logged in rmat file  
Elena,

I don't think the stack is corrupted because the program continued to run after this happened.  I will try the 
suggestion to not use optimized code or inline functions.

I used the system information tool to view memory address ranges for this process.
> [0xb84d2d8f] <no source code>
> [0xb84d2f52] <no source code>
> [0xb90e1a61] <no source code>
> [0xb55fd97] <no source code>
> [0xb91206db] <no source code>

The addresses are usually from the "library" section.  The fourth address from this example is one digit short, so it is
 actually 0x0b55fd97, which falls in the "heap" section.

Rex