Skip to main content

Z3_set_error_handler

Function Z3_set_error_handler 

Source
pub unsafe extern "C" fn Z3_set_error_handler(
    c: Z3_context,
    h: Z3_error_handler,
)
Expand description

Register a Z3 error handler.

A call to a Z3 function may return a non Z3_OK error code, when it is not used correctly. An error handler can be registered and will be called in this case. To disable the use of the error handler, simply register with h=NULL.

By default, newly created contexts install an internal default error handler that prints the error message and terminates the process via exit(1). While suitable for standalone CLI programs, calling raw exit() is unsafe when Z3 is invoked from within a managed runtime environment (such as Java/JNI under Android ART or the JVM, or .NET/CLR) or multi-threaded embedders: process termination can race with background runtime threads (e.g., JIT compilation or GC threads), producing crashes (SIGSEGV) in unrelated runtime threads. Embedders in managed runtimes should always register their own error handler or disable it by passing h=NULL and inspecting Z3_get_error_code.

\warning Log files, created using Z3_open_log, may be potentially incomplete/incorrect if error handlers are used.

ยงSee also