This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC / musing] Scoped exception handling in Linux userspace?
- From: Andy Lutomirski <luto at amacapital dot net>
- To: David Daney <ddaney dot cavm at gmail dot com>
- Cc: linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org
- Date: Thu, 18 Jul 2013 17:50:19 -0700
- Subject: Re: [RFC / musing] Scoped exception handling in Linux userspace?
- References: <CALCETrVioVM=pdCU3WhU6qDtGQyqML=btBRZ5+aV6bASj9GkOQ at mail dot gmail dot com> <51E88AEF dot 8040701 at gmail dot com>
On Thu, Jul 18, 2013 at 5:40 PM, David Daney <ddaney.cavm@gmail.com> wrote:
> On 07/18/2013 05:26 PM, Andy Lutomirski wrote:
>>
>> Windows has a feature that I've wanted on Linux forever: stack-based
>> (i.e. scoped) exception handling. The upshot is that you can do,
>> roughly, this (pseudocode):
>>
>> int callback(...)
>> {
>> /* Called if code_that_may_fault faults. May return "unwind to
>> landing pad", "propagate the fault", or "fixup and retry" */
>> }
>>
>> void my_function()
>> {
>> __hideous_try_thing(callback) {
>> code_that_may_fault();
>> } blahblahblah {
>> landing_pad_code();
>> }
>> }
>
>
> How is this different than throwing exceptions from a signal handler?
Two ways. First, exceptions thrown from a signal handler can't be
retries. Second, and more importantly, installing a signal handler in
a library is a terrible idea.
--Andy