BUG: Unhandled Exception Filter Not Called Inside Debugger (173652)
The information in this article applies to:
- Microsoft Win32 Application Programming Interface (API), when used with:
- the operating system: Microsoft Windows 95
- the operating system: Microsoft Windows 98
- the operating system: Microsoft Windows Millennium Edition
- the operating system: Microsoft Windows NT 3.5
- the operating system: Microsoft Windows NT 3.51
- the operating system: Microsoft Windows NT 4.0
- the operating system: Microsoft Windows 2000
- the operating system: Microsoft Windows XP
This article was previously published under Q173652 SYMPTOMS
Win32 processes can install an unhandled exception filter function to catch
exceptions that are not handled in a __try/__except block on a process-wide
basis. When debugging such a process, you find that the unhandled exception
filter is never executed, even when you put a breakpoint inside it.
However, when the process is not being debugged, its unhandled exception
filter is called as expected.
CAUSE
When called from a process being debugged, the UnhandledExceptionFilter()
Win32 API function does not call the application-installed unhandled
exception filter.
RESOLUTION
UnhandledExceptionFilter should call the application-installed unhandled
exception filter for processes that are being debugged in addition to those
not being debugged.
One way to debug an unhandled exception filter function is to put a
__try/__except block around all of the code inside the main() or WinMain()
function as follows:
void main (int argc, char **argv)
{
__try
{
// all of code normally inside of main or WinMain here...
}
__except (MyUnFilter (GetExceptionInformation()))
{
OutputDebugString ("executed filter function\n");
}
}
This work around behaves slightly differently from an unhandled exception
filter in that it will only be called for the thread executing the main()
or WinMain() function. If you are debugging a multithreaded application,
then you will need to add a similar __try/__except block inside of each
thread function.
If you don't want to add new __try/__except blocks to debug an unhandled
exception filter, you should use other methods such as assert, trace
outputs, and debugging code to validate the behavior of the exception
handler.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
Modification Type: | Minor | Last Reviewed: | 9/27/2004 |
---|
Keywords: | kbbug kbExceptHandling kbKernBase kbpending KB173652 |
---|
|