trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
252 stars 11 forks source link

CLPZ:monotonic: segfault #527

Closed flexoron closed 2 months ago

flexoron commented 2 months ago

v2.50.31

Note: # step by step added

$ tpl
?- use_module(library(clpz)), assertz(clpz:monotonic).
   true.

?- #\0 #= Y, Y #= -2 * X.  % Y,Y,X
   throw(error(instantiation_error,instantiation_error(unknown(_197),1))).

?- #\0 #= #Y, Y #= -2 * X. % #Y,Y,X 
   throw(error(instantiation_error,instantiation_error(unknown(_2824),1))).

?- #\0 #= #Y, Y #= -2 * #X. % #Y,Y,#X
   clpz:((-2* #X)#= #_A), clpz:((-2* #_B)#= #Y), Segmentation fault (core dumped)

$ tpl
?- use_module(library(clpz)),assertz(clpz:monotonic).
   true.
?- #\0 #= #Y, #Y #= -2 * #X. % #Y,#Y,#X
   clpz:(-2* #X#= #_A), clpz:(-2* #_B#= #Y), clpz:(Y in inf.. -2\/2..sup), clpz:(X in inf.. -1\/1..sup).
?- 
% Here, it works:
?- 4 #= #Y, Y #= -2 * X. % #Y,Y,X
   throw(error(instantiation_error,instantiation_error(unknown(_8),1))).
?- 4 #= #Y, Y #= -2 * #X. % #Y,Y,#X
   Y = 4, X = -2.
?- 3 #= #Y, Y #= -2 * #X. % #Y,Y,#X
   false.

Note: Scryer Prolog does not expect 'full-fledged' variables.

$ scryer-prolog
?- assertz(clpz:monotonic).
   true.
?- #\0 #= #Y, Y #= -2 * X. % #Y,Y,X
   error(instantiation_error,instantiation_error(unknown(_647767),1)).

?- #\0 #= #Y, Y #= -2 * #X. % #Y,Y,#X (tpl's segfault)
   clpz:(Y in inf.. -2\/2..sup), clpz:(-2* #X#= #Y), clpz:(X in inf.. -1\/1..sup).
?-