On Thu, 29 May 2025 at 18:26, Tom Lane <t...@sss.pgh.pa.us> wrote:

>
> Go there and use the "keyword search" for "longjmp" --- they
> don't seem to make it possible to bookmark individual pages.
>
> Indeed, you are fully correct. I didn't analyse the code well enough. The
equivalent code
for PG_TRY/PG_FINALLY/PG_END_TRY will appear like the following:

do {
    jmp_buf *_save_exception_stack = PG_exception_stack;
    jmp_buf _local_sigjmp_buf;
    bool _do_rethrow = false;

    if (setjmp(_local_sigjmp_buf) == 0)
    {
        PG_exception_stack = &_local_sigjmp_buf;
        /* try here */
        longjmp(_local_sigjmp_buf, 1); /* elog ERROR */
    }
    else
        _do_rethrow = true;

    {
        PG_exception_stack = _save_exception_stack;
        /* catch */
    }

    if (_do_rethrow)
        pg_re_throw();

    PG_exception_stack = _save_exception_stack;
    /* finally */
} while (0);

There is no problem here. We only change _do_rethrow after longjmp.
Apparently, we're
dealing with a false positive warning here. Not sure, but it could be
something like [0]. The
correct solution in this case would be to disable clobbered warning.

[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161

-- 
Best regards,
Maxim Orlov.

Reply via email to