[e-lang] Notes from latest Joe-E meeting

David Hopwood david.hopwood at industrial-designers.co.uk
Sun Apr 29 12:48:19 EDT 2007


[repost after changing address; sorry if this is a duplicate]

Tyler Close wrote:
> On 4/26/07, Mark Miller <erights at gmail.com> wrote:
> 
>>- There is an attack with try-finally and VirtualMachineError.
>>     try {
>>        ... X ...
>>     } catch (final Error reason) {
>>       throw JoeE.abort(reason);
>>     } finally {
>>        ... Y ...
>>     }
> 
> We could change the boilerplate for a finally clause to:
> 
>     try {
>         ...
>     } catch (final Error e) {
>         while (true) { try { JoeE.abort(e); break; } catch (Throwable t) {} }
>         throw e;
>     } finally {
>         ...
>     }

That doesn't work. A VirtualMachineError can still be thrown during the
'while (true) ... throw e;' block, and not caught by the 'catch (Throwable t)'.

> Another possibility:
> 
>     Error abort = null;
>     try {
>         ... anything but assignment to abort ...
>     } catch (final Error e) {
>         abort = e;
>     } finally {
>         if (null != abort) { throw abort; }
          ...
>     }

[I've added '...' where user code would go.]

This still does not guarantee the required semantics -- what if a
VirtualMachineError occurs just before 'abort = e;'?

Remember, VirtualMachineErrors are *entirely* nondeterministic and can happen
at any time (at least as far as the Java spec is concerned, and we don't really
want to rely on properties of specific Java implementations). They do not
necessarily only occur at uses of 'new' or method calls.

-- 
David Hopwood <david.hopwood at industrial-designers.co.uk> (note new address)




More information about the e-lang mailing list