Chapter Contents

Previous

Next
Handling Exceptions in SAS/C

blkjmp Handler

blkjmp handlers are called during unwinding for an exception. A blkjmp handler is called after stack unwinding has called all auto destructors for the current function as well as functions called by this function. The unwind process is suspended during the blkjmp handler and the information necessary to restart it is saved in the jmp_buf specified by the blkjmp call's argument.

Since the unwind process is suspended while the blkjmp handler is executing, the unwind process is not visible to std::uncaught_exception. This means that the result of std::uncaught_exception will be false if it would have been false prior to the throw that started the suspended unwind process.

Note:    It is possible to bypass the unwind process by exiting the blkjmp handler in some other way than longjmp with the information saved in the jmp_buf or by using longjmp from a user function called by the unwinder. This is not a recommended practice. It prevents proper cleanup of the exception after all handlers have completed. The memory allocated to the exception will not be released in this case nor will the exception object destructor be called. If this happens repeatedly then memory allocation problems may occur. Also, the effects are unpredictable if a blkjmp handler returns to its caller and the saved jmp_buf information is used later.  [cautionend]


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.