Safely working with libraries that use setjmp/longjmp #1656
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
(as discussed on IRC):
Some C environments/libraries use setjmp+longjmp for control flow. e.g. writing PostgreSQL Extensions or the Lua C API.
A C function
longjmp
-ing out may result in zig code not being run. This may includedefer
-d code for cleanup, which will result in various resource leaks or even deadlocks.Proposed Solution
Functions should gain a
may longjmp
annotation (possibly with an arbitrary ID?).may longjmp
unless a matchingsetjmp
annotation is found.defer
occurs before amay longjmp
function call in the same (or child) scope.It is fine if the
defer
block occurs after the call to themay longjmp
function, as thelongjmp()
would already have happened.The text was updated successfully, but these errors were encountered: