RAD Studio
|
Access errors result from improper memory management.
When CodeGuard detects accesses to freed memory blocks or deleted objects, it can identify where each block was allocated and deleted. Enable the Delay Free option using the CodeGuard Configuration dialog box to use this feature.
The following are types of access errors:
In the following example, CodeGuard identifies the line where an invalid access occurrs. CodeGuard then indicates where the memory block was allocated and subsequently freed.
Error 00004. 0x100430 (Thread 0xFFF87283): Access in freed memory: Attempt to access 19 byte(s) at 0x00B423DC. strcpy(0x00B423DC, 0x004091CA ["Copy to free block"]) | lang.cpp line 106: | | free(buf_h); |> strcpy(buf_h, "Copy to free block"); | | //-----------------------// Call Tree: 0x004011F1(=LANG.EXE:0x01:0001F1) lang.cpp#106 0x00407EE5(=LANG.EXE:0x01:006EE5) The memory block (0x00B423DC) [size: 21 bytes] was allocated with malloc | lang.cpp line 80: | char * pad = (char *) malloc(200); | // An array in the RTL heap. |> char * buf_h = (char *) malloc(21); | char * p; | // A scratch buffer. Call Tree: 0x004011A1(=LANG.EXE:0x01:0001A1) lang.cpp#80 0x00407EE5(=LANG.EXE:0x01:006EE5) The memory block (0x00B423DC) was freed with free | lang.cpp line 105: | //-------------// | |> free(buf_h); | strcpy(buf_h, "Copy to free block"); | Call Tree: 0x004011E5(=LANG.EXE:0x01:0001E5) lang.cpp#105 0x00407EE5(=LANG.EXE:0x01:006EE5)
In the following example, the pointer p became invalid when getBadLocal returned from execution. No additional information is provided because the stack frame for getBadLocal was automatically removed.
Error 00005. 0x120400 (Thread 0xFFF87283): Access in uninitialized stack: Attempt to access 20 byte(s) at 0x0072FC88. memcpy(0x0072FCC4, 0x0072FC88, 0x14 [20]) | lang.cpp line 112: | //-----------------------// | p = getBadLocal(); |> memcpy(buffer, p, 20); | | //-------------// Call Tree: 0x00401208(=LANG.EXE:0x01:000208) lang.cpp#112 0x00407EE5(=LANG.EXE:0x01:006EE5)
In the following example, an allocation was made for buf_s on the stack. However, the strcpy function writes just below the beginning of the valid stack region. CodeGuard identifies this as an error even if the string is only one byte long.
Error 00002. 0x110400 (Thread 0xFFF87283): Access in invalid stack: Attempt to access 22 byte(s) at 0x0072FD8F. strcpy(0x0072FD8F, 0x00409188 ["This string is long!\n"]) | LANG.CPP line 93: | | // Stack underrun: |> strcpy(buf_s -1, "This string is long!\n"); | | // Global data overrun: Call Tree: 0x004011C5(=LANG.EXE:0x01:0001C5) LANG.CPP#93 0x00407EED(=LANG.EXE:0x01:006EED)
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|