unwind behavior
Allen Wirfs-Brock
Allen_Wirfs-Brock at Instantiations.com
Mon Jul 1 17:24:08 UTC 2002
ANSI doesn't say anything about this because it doesn't talk about
processes. However, if it had covered this, it would have said something like:
"If the current state of a Process that is explicitly terminated includes
any block activations with terminationBlocks then the terminationBlocks
will be executed in the reverse of the order in which their corresponding
receiver blocks were evaluated. Explicitly terminating a process whose
termination processing has already been initiated has no effect upon the
terminating process."
Basically, when a process is terminated it's stack should be unwound and
any unwind blocks associated with active blocks should be executed. The
problem you describe seems to reflect a bug in the Squeak implementation of
ensure. An ensure block is supposed to execute after the activation of
the block it "protects" has been discarded. In other words, before
execution of the ensure block begins the stack should be trimmed back to
just before the protected activation and any mechanism for triggering
subsequent execution of the ensure blocks should be eliminated. Then the
actual activation of the ensure block is just a normal block activation,
there is nothing special about it.
It sounds like the squeak implementation is not cleaning up before
activating the ensure block. The terminate should find neither the
protected block nor a pending ensure block. All it should see is a normal,
unprotected block activation. The bug might be related to Squeak's lack of
closures, as closures certainly simplify the implementation of
ensure/ifCurtailed.
Allen_Wirfs-Brock at Instantiations.com
At 08:01 PM 6/30/2002 +0200, Andreas Raab wrote:
>Hi,
>
>Just a question: Does anyone know what the *expected* behavior for
>terminating a process is where an unwind block is currently under
>evaluation?! E.g., a simple test case is:
>
> process := [[3+4] ensure:[
> Transcript cr; show: 'Unwinding...'.
> Processor activeProcess suspend.
> Transcript show:'done'.
> ]] fork.
> (Delay forMilliseconds: 100) wait.
> process terminate.
>
>Right now this raises an error in Squeak (attempting to evaluate a block
>which is already evaluated) so this is clearly wrong. But what *is* the
>expected behavior in this case?! Does somebody know what ANSI has to say
>about this problem?
>
>Cheers,
> - Andreas
More information about the Squeak-dev
mailing list
|