On 6/21/22 9:34 AM, Robert E. Griffith wrote:
In my loadable builtin I have a error handling mechanism based on
setjmp/longjump. I thought I would use theĀ unwind_prot.h/c mechanism to
clean up resources but even though I am calling begin_unwind_frame() and
discard_unwind_frame() in pairs, sometimes the discard fails because the
tag set by begin_unwind_frame() does not exist. I think its after my
builtin invokes the source.def builtin.
Maybe I dont fully understand the unwind mechanism. I thought it is a stack
and as long as I leave it as it was (ie. each begin is followed by a
discard or a run) that it should play nice with bashes' use of it.
It's fine to use the unwind-protect mechanism in a builtin; existing static
builtins already do.
If you're wondering how or when the stack gets manipulated, debug and put
breakpoints in run_unwind_frame and discard_unwind_frame and see what's
happening.