[squeak-dev] The Inbox: Tests-jr.457.mcz

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sun Apr 25 23:50:20 UTC 2021


Thanks, that's a valid example I think.
I have sketched a new solution that still enables to rearmHandlerDuring:
Reminder: the semantics of rearmHandlerDuring: is to let the handler
be active, even if it is an inner handler.

The only solution that I've found is to have both temps in on:do:
- isHandlerActive to prevent re-entrancy
- isHandlerRearmed to allow both re-entrancy and inner handler activation

I've started with only the last one, but I've then got an infinite
loop in testHandlerReentrancy.

The principle is again to mark handleSignal: with <primitive: 199>
Then, during the scan for active handler, if we encounter a
handleSignal: context, then it means that the exception was signalled
when handling another exception (via the action block of a handler).
If that's the case, instead of jumping to (handlerContext
nextActiveHandler) of the prior exception (handleSignalContext tempAt:
1) like I proposed in the past (or like in Cuis), we continue scanning
the stack linearly for the case of a rearmed handler...

Note that we still want to rearm the inner handlers in case of
ProgressInitiationException...



Le dim. 25 avr. 2021 à 17:39, <commits at source.squeak.org> a écrit :
>
> A new version of Tests was added to project The Inbox:
> http://source.squeak.org/inbox/Tests-jr.457.mcz
>
> ==================== Summary ====================
>
> Name: Tests-jr.457
> Author: jr
> Time: 25 April 2021, 5:39:42.729128 pm
> UUID: 38bb7c0a-ba18-0e43-866f-4f252c20a2d8
> Ancestors: Tests-nice.455
>
> Test case for precise handler reactivation when nested exceptions are signalled and resumed.
>
> At the moment of writing this, this is broken in Squeak Trunk and the test case would run endlessly if there were no timeout. The reason is that the inner error handler is reactivated when the signal emitted by it is resumed.
>
> Related versions:
> - Kernel-nice.1384
> - Kernel-nice.1391
> - ToolBuilder-Kernel-nice.141
> - ToolBuilder-Kernel-nice.142
>
> =============== Diff against Tests-nice.455 ===============
>
> Item was added:
> + ----- Method: ExceptionTests>>testHandlersReactivatedOnResume (in category 'tests - outer') -----
> + testHandlersReactivatedOnResume
> +       <timeout: 0.5>
> +       | result |
> +       result := [
> +               [
> +                       [self error: 'to be handled by the inner handler']
> +                               on: Error do:
> +                                       [:e |
> +                                       Warning signal: 'to be resumed by the middle handler'.
> +                                       "After resuming from the Warning, its handler must be active again."
> +                                       Warning signal: 'to be resumed by the middle handler'.
> +                                       self error: 'to be handled by the outer handler'.
> +                                       e return: 'inner result']]
> +                       on: Warning do:
> +                               [:e | e resume "This must not rearm the inner Error handler above"]]
> +               on: Error do:
> +                       [:e | e return: 'outer result'].
> +       self assert: 'outer result' equals: result.!
>
>


More information about the Squeak-dev mailing list