Image freeze when a continuation is called

157 views Asked by At

I'm trying to test the continuation facility in Pharo, with this code(in the playground):

| cont f |
f:=[
    |i|
    i:=0.
    Continuation currentDo: [ :cc | cont:=cc ].
    i:=i+1.
].
f value. "1"
cont. "a Continuation"

However, as soon as I call the continuation saved in cont(replacing cont. by cont value.), the image freezes immediately, and I have to press atl+. to gain back control.

VM version: VM: NBCoInterpreter NativeBoost-CogPlugin-GuillermoPolito.19 uuid: acc98e51-2fba-4841-a965-2975997bba66 May 15 2014 NBCogit NativeBoost-CogPlugin-GuillermoPolito.19 uuid: acc98e51-2fba-4841-a965-2975997bba66 May 15 2014 https://github.com/pharo-project/pharo-vm.git Commit: ed4a4f59208968a21d82fd2406f75c2c4de558b2 Date: 2014-05-15 18:23:04 +0200 By: Esteban Lorenzano <[email protected]> Jenkins build #14826

Pharo version: [version] 4.0 #40614

Thanks.

Edit: I was stupid, didn't think this through...

2

There are 2 answers

3
Max Leske On BEST ANSWER

You've effectively created an infinite loop by reevaluating the same code again and again. You can see that if you debug the code and step through it. The original context will always be restored and then evaluated starting with the first expression following the #currentDo: send. This is exactly what the continuation is supposed to do: save the current position in the execution and restart there later on.

6
EstebanLM On

I do not have a Fedora to test, however I tried your code in Ubuntu, using this version of Pharo:

wget -O- get.pharo.org/40+vm | bash
./pharo-ui Pharo.image

and your code seems to work properly :(

In case this error persists, could you be more specific about the version of the vm you are using?:

./pharo Pharo.image --version

And the version of Pharo you are using?:

./pharo Pharo.image printVersion

Also, send us the crash.dmp file would help a lot.