help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can I use unwind_* mechanism in my loadable builtin?


From: Chet Ramey
Subject: Re: Can I use unwind_* mechanism in my loadable builtin?
Date: Tue, 21 Jun 2022 11:52:45 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

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.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]