Exception Errors

From Appmethod Topics
Jump to: navigation, search

Go Up to CodeGuard Errors Index

When a system exception occurs, CodeGuard reports the run-time error using information provided by the operating system. If possible, the CodeGuard log shows where your application caused the exception. CodeGuard does not trap or redirect the exception or otherwise interfere with normal program behavior.

The following exceptions illustrate how CodeGuard exception reporting:

  • General Protection Fault
  • Divide by zero

General Protection Fault

In the following example, CodeGuard provides information on a general protection fault (Intel system exception 0xD). In addition to the location of the source code that caused the exception, the log shows where the memory was allocated and subsequently freed. The reported incorrect value is a result of accessing a byte pattern that CodeGuard uses to identify invalid memory locations.

Error 00003. 0x400003 (Thread 0x0090):
Exception 0xC0000005: Access violation at 0x80828082.
| gpfault.c line 32:
|    {
|       q = p[3];
|>      *q = 1;
|    }
| }
Call Tree:
   0x004010E5(=GPFAULT.EXE:0x01:0000E5) gpfault.c#32
   0x00406B29(=GPFAULT.EXE:0x01:005B29)

The bogus value (0x80828082) was most likely retrieved by accessing a(n)
 memory block that has already been freed
The memory block (0x008322A4) [size: 16 bytes] was allocated with malloc
| gpfault.c line 17:
|     int *q;
|
|>   p = malloc(sizeof(*p) * 4);
|
|    /*  Initialize p */
Call Tree:
   0x00401094(=GPFAULT.EXE:0x01:000094) gpfault.c#17
   0x00406B29(=GPFAULT.EXE:0x01:005B29)

The memory block (0x008322A4) was freed with free
| gpfault.c line 17:
|     int *q;
|
|>   p = malloc(sizeof(*p) * 4);
|
|    /*  Initialize p */
Call Tree:
   0x00401094(=GPFAULT.EXE:0x01:000094) gpfault.c#17
   0x00406B29(=GPFAULT.EXE:0x01:005B29)

Divide By Zero

In the following example, CodeGuard identifies the location in source code where division by zero (Intel system exception 0x0) occurred.

Error 00001. 0x400000 (Thread 0x008B):
Exception 0xC0000094:
| ZERODIV.C line 9:
| {
|  x = 1;
|> return x / y;
| }
|
Call Tree:
   0x0040109C(=ZERODIV.EXE:0x01:00009C) ZERODIV.C#9
   0x00406321(=ZERODIV.EXE:0x01:005321)

See Also