例外エラー
システム例外が発生すると、CodeGuard は、オペレーティング システムから提供される情報を使って実行時エラーを報告します。可能であれば、アプリケーションのどこで例外が発生したかが CodeGuard のログに示されます。CodeGuard は、例外のトラップやリダイレクトなど、プログラムの通常の動作を妨げることはしません。
以下の例外は、CodeGuard による例外報告の例を示します。
- 一般保護例外
- ゼロ除算
一般保護例外
以下の例で、CodeGuard は、一般保護例外(Intel システム例外 0xD)に関する情報を提供します。ログには、例外が発生したソース コードの箇所に加えて、メモリがどこで割り当てられ、その後どこで解放されたかも示されています。CodeGuard で無効なメモリ位置を特定するのに使用されるバイト パターンにアクセスした結果が、不正な値として報告されます。
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)
ゼロ除算
以下の例で、CodeGuard は、ソース コードにおけるゼロ除算(Intel システム例外 0x0)の発生箇所を特定しています。
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)