an exception caught in a finally block swallows the exception of the outer try

Description

The inner try exception handling clears the exception status of the outer try, making it return successfully instead of rethrowing.
In the following snippet, prn is executed althought it should be dead code.

Environment

None

Activity

Show:
Alex Miller
January 10, 2020, 6:48 PM

Released in 0.7.559

Alex Miller
January 9, 2020, 12:48 PM

Patch applied

Kevin Downey
January 4, 2020, 12:21 AM

rebased, regenerated patch

Kevin Downey
January 2, 2019, 12:30 AM

0002-async-220-generate-two-finally-blocks.patch
is based on top of the patch for

finallys can either be entered in the normal course of execution or
when handling an exception. so a finally X behaves sort of like

(try (let [r (code)] (X) r) (catch Throwable t (X) (throw t)))

previously the :try code was generating a single finally block which
tried to determine if it needed to rethrow an exception or not by
looking at the value of CURRENT-EXCEPTION, but this didn't work
correctly in certained nested try/catches.

so now the :try code generates two finally blocks, one that rethrows
and one that doesn't. the rethrow block goes on the exception frames
stack, and the not rethrowing block is jumped to at the end up the
body and each exception handler.

the patch also gets rid of CURRENT-EXCEPTION entirely, as it was only used by finally to determine if it needed to throw or not

leonoel
November 29, 2018, 8:56 AM

This patch doesn't fix the issue.
The problem with current design is that only one exception at a time can be stored (in the CURRENT-EXCEPTION slot) so when you have to deal with more than one the latest overwrite the previous.

Fixed
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Kevin Downey

Reporter

leonoel

Labels

Patch

Code