다음을 통해 공유


PREfast Warning 312 (Windows CE 5.0)

Send Feedback

312 - Possible infinite loop.
Additional Information: Use of the constant EXCEPTION_CONTINUE_EXECUTION in the exception-filter expression of a try-except.

This message indicates that PREfast has detected the use of the constant EXCEPTION_CONTINUE_EXECUTION (or another constant that evaluates to -1) in the filter expression of a structured exception handler.

Use of the constant value EXCEPTION_CONTINUE_EXECUTION can lead to an infinite loop. If an exception is raised by hardware, the instruction that caused the exception is restarted. If the address that caused the exception is still bad, another exception occurs and is handled in the same way. This results in an infinite loop.

An explicit call to RaiseException does not directly result in an infinite loop, but it continues execution of the code in the protected block. This can be unexpected and can lead to an infinite loop if RaiseException was used to avoid de-referencing an invalid pointer.

In addition, when EXCEPTION_CONTINUE_EXECUTION is used, the handler block of the structured exception handler is not executed.

EXCEPTION_CONTINUE_EXCEPTION should usually only be returned by a function called in the filter expression, which has a chance to fix the pointer that caused the exception or the underlying memory.

Example

Defective Source

__try {
    *ptr = '\0';
} __except (EXCEPTION_CONTINUE_EXCEPTION) {
    // This block is never executed.

    ;
}

Corrected Source

__try {
    *ptr = '\0';
} __except (ExceptionFilter(ptr, GetExceptionCode())) {
    // Block may be executed depending on result of call
    // to ExceptionFilter.

    ;
}

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.