From: Richard Henderson <richard.henderson@linaro.org>
To: Eric Blake <eblake@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>
Cc: "Emilio G . Cota" <cota@braap.org>, Fam Zheng <famz@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH 0/5] Scoped locks using attribute((cleanup))
Date: Fri, 15 Dec 2017 09:50:41 -0600 [thread overview]
Message-ID: <59ab84cc-ec75-b55b-a6db-519dc4589727@linaro.org> (raw)
In-Reply-To: <0895424e-ad82-be08-4232-0f46369a946b@redhat.com>
On 12/12/2017 02:41 PM, Eric Blake wrote:
> On 12/11/2017 03:32 PM, Paolo Bonzini wrote:
>> On 11/12/2017 15:11, Eric Blake wrote:
>>> I don't know if there is a way to make gcc insert stack-unwind
>>> directives that are honored across longjmp (I know C++ does it for
>>> exceptions; so there may be a way, and I just don't know it).
>>
>> Probably -fexceptions.
>>
>
> Well, that's what 'info gcc' mentions:
>
> 'cleanup (CLEANUP_FUNCTION)'
> The 'cleanup' attribute runs a function when the variable goes out
> of scope. This attribute can only be applied to auto function
> scope variables; it may not be applied to parameters or variables
> with static storage duration. The function must take one
> parameter, a pointer to a type compatible with the variable. The
> return value of the function (if any) is ignored.
>
> If '-fexceptions' is enabled, then CLEANUP_FUNCTION is run during
> the stack unwinding that happens during the processing of the
> exception. Note that the 'cleanup' attribute does not allow the
> exception to be caught, only to perform an action. It is undefined
> what happens if CLEANUP_FUNCTION does not return normally.
>
> but adding -fexceptions to my sample program does NOT make a difference
> (apparently, unwind cleanup triggered by C++ exceptions is NOT the same
> as unwinding done by longjmp()).
longjmp isn't an exception, and so doesn't run stack cleanups. You'd need to
use _Unwind_Throw ... except for the fact that C doesn't have a mechanism by
which we can catch it.
We would really need to use C++ and throw to get those semantics.
r~
next prev parent reply other threads:[~2017-12-15 15:50 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-08 10:55 [Qemu-devel] [RFC PATCH 0/5] Scoped locks using attribute((cleanup)) Paolo Bonzini
2017-12-08 10:55 ` [Qemu-devel] [PATCH 1/5] compiler: add a helper for C99 inline functions Paolo Bonzini
2017-12-08 10:55 ` [Qemu-devel] [PATCH 2/5] lock-guard: add scoped lock implementation Paolo Bonzini
2017-12-08 15:30 ` Stefan Hajnoczi
2017-12-08 17:56 ` Paolo Bonzini
2017-12-08 20:12 ` Eric Blake
2017-12-11 10:16 ` Stefan Hajnoczi
2017-12-11 13:51 ` Eric Blake
2017-12-12 9:16 ` Stefan Hajnoczi
2017-12-08 10:55 ` [Qemu-devel] [PATCH 3/5] qemu-timer: convert to use lock guards Paolo Bonzini
2017-12-08 14:26 ` Stefan Hajnoczi
2017-12-08 10:55 ` [Qemu-devel] [PATCH 4/5] qht: " Paolo Bonzini
2017-12-08 14:27 ` Stefan Hajnoczi
2017-12-08 10:55 ` [Qemu-devel] [PATCH 5/5] thread-pool: " Paolo Bonzini
2017-12-08 15:13 ` Stefan Hajnoczi
2017-12-08 18:12 ` Paolo Bonzini
2017-12-08 20:02 ` Eric Blake
2017-12-11 10:23 ` Stefan Hajnoczi
2017-12-11 22:03 ` Paolo Bonzini
2017-12-08 19:50 ` Eric Blake
2017-12-11 6:35 ` Peter Xu
2017-12-08 19:40 ` [Qemu-devel] [RFC PATCH 0/5] Scoped locks using attribute((cleanup)) Eric Blake
2017-12-11 9:38 ` Peter Maydell
2017-12-11 14:11 ` Eric Blake
2017-12-11 21:32 ` Paolo Bonzini
2017-12-12 20:41 ` Eric Blake
2017-12-15 15:50 ` Richard Henderson [this message]
2017-12-11 6:40 ` no-reply
2017-12-11 6:40 ` no-reply
2017-12-11 6:46 ` no-reply
2017-12-11 22:06 ` Emilio G. Cota
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59ab84cc-ec75-b55b-a6db-519dc4589727@linaro.org \
--to=richard.henderson@linaro.org \
--cc=cota@braap.org \
--cc=eblake@redhat.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).