Debugging Dynamic Memory Usage Errors Using NonStop Native Inspect White Paper

__rtc_event (ecode=RTC_BAD_STRCPY, pointer=0x8429d18, pclist=0x8404a4c,
size=20)
at c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:1901
c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:1901: Guardian or User Defined
Error 13
(eInspect 1,1193): bt
#0 __rtc_event (ecode=RTC_BAD_STRCPY, pointer=0x8429d18, pclist=0x8404a4c,
size=20)
at c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:1901
#1 0x7800cbc0:0 in search_addr (pointer=0x8429d18 "", len=26,
this_c_i=0x840dac4, ecode=RTC_BAD_STRCPY)
at c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:4391
#2 0x7800d150:0 in libc_mem_common (addr=0x8429d18, len=26,
ecode=RTC_BAD_STRCPY)
at c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:4556
#3 0x7800e510:0 in strcpy (d=<optimized out>, s= <optimized out>)
at c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:4810
#4 0x70000b60:0 in main () at \PELICAN.$DATA4.USER.EX3C:11
#5 0x70000dc0:0 in _MAIN () at \SPEEDY.$RLSE.T8432H02.CPLMAINC:46
(eInspect 1,1193): c
Continuing.
warning: memcpy corrupted (address = 0x08429cfd size = 10)
#1 main() at \PELICAN.$DATA4.USER.EX3C:7
#2 _MAIN() at \SPEEDY.$RLSE.T8432H02.CPLMAINC:46
warning: Use command backtrace (bt) to see the current context.
Ignore top 4 frames belonging to leak detection library of eInspect.
__rtc_event (ecode=RTC_BAD_MEMCPY, pointer=0x8429cfd, pclist=0x8404a38,
size=10)
at c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:1901
c:\t1237\h0616\wdb\build\ia64-hp-nsk-native\
gdb\../../../Src/gnu/gdb\infrtc.c:1901: Guardian or User Defined
Error 13.
Detecting Out-of-Bounds Writes with the Bounds-Checking Feature
The set heap-check bounds <on/off> command toggles the bounds-checking feature in Native
Inspect. When bounds-checking is enabled, Native Inspect allocates extra space (guard bytes) at
the beginning and end of a block during allocation and fills this space with a specific pattern.
When the blocks are freed, the debugger verifies if the patterns are intact. If the patterns are
corrupted, the debugger detects underflow or overflow errors and reports the corruption. Example
4 illustrates the bounds-checking feature.
The bounds-checking feature detects overflow and underflow errors only when the write operation
occurs within the guard bytes.
Example 4 Bounds-checking to detect out-of-bounds writes
Sample Program
1 #include <stdio.h>
2
3 int main()
4 {
5 char *cp = (char*)malloc(100);
6 cp[-1] = 100;
Memory-Debugging Features of Native Inspect 15