PBSetUnhandledExceptionFilter

VOID PBSetUnhandledExceptionFilter (LPTOP_LEVEL_EXCEPTION_FILTER pfnExceptionFilter)

Parameters

pfnExceptionFilter Pointer to a function to execute when an unhandled exception occurs.

Remarks

This function is included only for completeness and can be safely ignored in almost all cases.

Because Paul Bunyan provides synchronized access to resources shared throughout a machine, care must be taken when unusual conditions occur. It is not acceptable to have a process that encounters an unusual condition or a misbehaving process impact all other processes that share those resources. Unfortunately, this is exactly what would occur if the system default unhandled exception filter were allowed to execute. For this reason, the Paul Bunyan library intercepts all unhandled exceptions that occur while a thread in the process that encounters the exception is holding the mutual exclusion semaphore used to serialize access to the IPC buffer. In such a scenario, the library will log an error to the application event log and terminate the process.

PBSetUnhandledExceptionFilter provides a mechanism to override the library default behavior when an unhandled exception occurs in a process while a thread in that process is logging. (The exception may occur on the logging thread or on a separate thread in the process.) It is strongly recommended that the code executed in this case should not interact with the user or in any way cause a delay. While the unhandled exception filter function is being executed, all other processes on the machine that are attempting to log will be suspended. Showing a message box could hang the entire machine until the user notices it.

Note that these considerations only apply to unhandled exceptions. Exceptions that are trapped locally, either by Paul Bunyan code or user code, are not affected. It also applies only to unhandled exceptions occurring while a Paul Bunyan library function is being executed, which should normally be a very small fraction of the time since we’re so fast.

For more information on this topic, see notification message number 502 in the Notifications and Errors appendix.