qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH 0/5] Scoped locks using attribute((cleanup))


From: Eric Blake
Subject: Re: [Qemu-devel] [RFC PATCH 0/5] Scoped locks using attribute((cleanup))
Date: Tue, 12 Dec 2017 14:41:52 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

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()).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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