[squeak-dev] The Trunk: Kernel-nice.1384.mcz

Jakob Reschke jakres+squeak at gmail.com
Mon Apr 19 20:37:11 UTC 2021


Hi Nicolas,

I seem to have a Heisenbug now because of this:
In case you have the Git tools loaded, you should have a
SquotImageStoreTest in your image. After loading this version and the
follow-up fix versions of Kernel, the test
SquotImageStoreTest>>testApplyPatch fails.

The test fails because an initialize method is not removed from the class
to be patched. When the method is about to be
MCMethodDefinition>>#unload-ed, it makes a CurrentEnvironment lookup in
MCMethodDefiction>>actualClass, and it returns a wrong environment. It
seems that the handler to set the dynamic Environment further up in the
stack is not activated for this particular lookup. Yet if I debug through
the procedure, everything works as it should. If I let the test run on its
own, it fails.

But if I replace in MCMethodDefinition this:

actualClass
    ^ self actualClassIn: Environment current

by this:

actualClass
    Environment current.
    ^ self actualClassIn: Environment current

Then the test is suddenly green again. I suppose that is not acceptable. ;-)

It also works with Notification signal instead of the extraneous
Environment current, so it seems like the signal handler stack is somehow
in a wrong state, which is corrected by emitting an extraneous signal. And
when I halt there to debug the situation, it also has to deal with extra
signals, which corrects the state, so I cannot inspect the incorrect one. I
didn't identify the reason for this behavior yet, so I am not sure whether
my exception handling has bugs somewhere or whether Squeak's exception
handling is bugged now.

Kind regards,
Jakob

Am So., 11. Apr. 2021 um 19:33 Uhr schrieb <commits at source.squeak.org>:

> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-nice.1384.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.1384
> Author: nice
> Time: 11 April 2021, 7:33:23.487481 pm
> UUID: ecb5db19-59bc-45f0-85d3-d9296a936a68
> Ancestors: Kernel-mt.1383
>
> Another attempt at fixing #testHandlerFromAction. Unlike previous
> attempts, this one preserves the expectations of #testHandlerReentrancy.
>
> The solution is to de-activate the handlers as we backtrack the stack, but
> to reactivate them before performing final exception handling actions (like
> resuming, resignalling or performing defaultAction). Indeed, those handlers
> must be able to handle a secondary exception raised in the course of this
> action.
>
> =============== Diff against Kernel-mt.1383 ===============
>
> Item was changed:
>   ----- Method: Context>>handleSignal: (in category 'private-exceptions')
> -----
>   handleSignal: exception
>         "Sent to handler (on:do:) contexts only.  If my exception class
> (first arg) handles exception
>          and the handler is active then execute my handle block (second
> arg), otherwise forward
>          this message to the next handler context.  If none left, execute
> exception's defaultAction
>          (see nil>>handleSignal:)."
>
>         | handlerActive val |
>         "If the context has been returned from the handlerActive temp var
> may not be accessible."
>         handlerActive := stackp >= 3 and: [(self tempAt: 3) == true].
>         (((self tempAt: 1) handles: exception) and: [handlerActive])
> ifFalse:
> +               [stackp >= 3 ifTrue: [self tempAt: 3 put: false].
> +               ^self nextHandlerContext handleSignal: exception].
> -               [^self nextHandlerContext handleSignal: exception].
>
>         exception privHandlerContext: self contextTag.
>         self tempAt: 3 put: false.  "disable self while executing handle
> block"
>         val := [(self tempAt: 2) cull: exception]
> +                       ifCurtailed: [self tempAt: 3 put: true].
> -                       ensure: [self tempAt: 3 put: true].
>         self return: val  "return from self if not otherwise directed in
> handle block"
>   !
>
> Item was added:
> + ----- Method: Context>>reactivateHandlers (in category
> 'private-exceptions') -----
> + reactivateHandlers
> +       "Private - sent to exception handler context only (on:do:).
> +       Reactivate all the handlers into the chain"
> +
> +       self tempAt: 3 put: true. "this is temporary handlerActive in
> #on:do:"
> +       self nextHandlerContext reactivateHandlers!
>
> Item was added:
> + ----- Method: Exception>>reactivateHandlers (in category 'priv
> handling') -----
> + reactivateHandlers
> +       "reactivate all the exception handlers in the context chain"
> +       self canSearchForSignalerContext
> +               ifTrue: [signalContext nextHandlerContext
> reactivateHandlers]!
>
> Item was changed:
>   ----- Method: Exception>>resignalAs: (in category 'handling') -----
>   resignalAs: replacementException
>         "Signal an alternative exception in place of the receiver."
>
> +       self reactivateHandlers.
>         self resumeUnchecked: replacementException signal!
>
> Item was changed:
>   ----- Method: UndefinedObject>>handleSignal: (in category 'bottom
> context') -----
>   handleSignal: exception
> +       "When no more handler (on:do:) context left in sender chain this
> gets called.  Return from signal with default action.
> +       Before doing that, reactivate the handlers so that they can catch
> eventual secondary exceptions raised by defaultAction."
> -       "When no more handler (on:do:) context left in sender chain this
> gets called.  Return from signal with default action."
>
> +       ^ exception reactivateHandlers; resumeUnchecked: exception
> defaultAction!
> -       ^ exception resumeUnchecked: exception defaultAction!
>
> Item was added:
> + ----- Method: UndefinedObject>>reactivateHandlers (in category 'bottom
> context') -----
> + reactivateHandlers
> +       "nothing to do for bottom context"
> +
> +       ^ self!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210419/77249e99/attachment.html>


More information about the Squeak-dev mailing list