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
268 stars 20 forks source link

uncaught memory overflow in ciaowasm (was Cannot distinguish error from failure") #52

Open Jean-Luc-Picard-2021 opened 2 years ago

Jean-Luc-Picard-2021 commented 2 years ago

There is a strange behaviour on my machine with the new Ciao WASM Playground:

?- time2(fac(s(s(s(s(s(s(s(s(s(s(n)))))))))), _)).
% walltime 520.0 ms
yes
?- time2(fac(s(s(s(s(s(s(s(s(s(s(s(n))))))))))), _)).
no
?- fail.
no

I guess JavaScript WASM run out of memory. But somehow the error is not noticed or ignored. Would it be possible to show the out of memory?

P.S.: Was using this code:

add(n, X, X).
add(s(X), Y, Z) :- add(X, s(Y), Z).

mul(n, _, n).
mul(s(X), Y, Z) :- mul(X, Y, H), add(Y, H, Z).

fac(n, s(n)).
fac(s(X), Y) :- fac(X, H), mul(s(X), H, Y).
jfmc commented 2 years ago

Thanks! This is definitely a bug.

jfmc commented 1 year ago

Looking at values reported by statistics/0 it seems that some memory overflow is not handled correctly.