ciao-lang / ciao

Ciao is a modern Prolog implementation that builds up from a logic-based simple kernel designed to be portable, extensible, and modular.
https://ciao-lang.org
GNU Lesser General Public License v3.0
272 stars 21 forks source link

(playground) Aborts cause state loss. #56

Closed Jean-Luc-Picard-2021 closed 4 weeks ago

Jean-Luc-Picard-2021 commented 2 years ago

Hi,

Not sure whether this ticket is redundant to "(ciaowasm) make '$yield'/0 interact with JS async" what is seen in the commits?

There is some state loss in manual abort:

?- assertz(foo).
yes

?- foo.
yes

?- repeat, fail.
{ Execution aborted }

?- foo.
{ERROR: No handle found for thrown exception error(
existence_error(procedure,'user:foo'/0),'user:foo'/0)}
aborted

And in timeout:

?- assertz(foo).
yes

?- repeat, fail.
{ABORTED: Time limit exceeded.}

?- foo.
{ERROR: No handle found for thrown exception error(
existence_error(procedure,'user:foo'/0),'user:foo'/0)}
aborted

https://ciao-lang.org/playground/

Expectation would be rather that this doesn't happen.

jfmc commented 2 years ago

Thank you. This is a known limitation similar to blocking IO. Timeouts are hard without asyncify or shared array buffers because there is no way for the executing thread to know that it has been asked to abort. Asyncify should be able but we've not measured the performance impact yet. Right now aborts restart the engine.

jfmc commented 2 years ago

Thanks. Sorry, I was confused with the long thread at SWI discourse. We'll try automatic yield but if there is some serious impact on performance, we will consider also other options (maybe optionally). For some workers losing the state is not an issue.

jfmc commented 1 year ago

Not fixed yet.

Jean-Luc-Picard-2021 commented 4 weeks ago

The workaround was to change the error message:

{ Execution aborted (resetting dynamic database) }

So I guess this is a wont fix.