[net.lang.prolog] Interesting Cprolog 1.5 bug

citrin@ucbvax.BERKELEY.EDU (Wayne Citrin) (11/09/86)

Here's an interesting bug in Cprolog 1.5 that I stumbled upon.
Take the following program:

main :- foo(_), replace_foo, fail.
foo(1).
replace_foo :- retract(foo(_)), assert(foo(2)), !.

(The cut is needed to remove the choice point set up by the retract,
but that's another bug.)

Run this program by issuing the query ?- main.
The program terminates and fails.  The call to foo/1 in main does not set
up a choice point because there is only one clause in foo at the time the
call is made.  This is the behavior one would expect.

Now, put the interpreter in debug mode and issue the same query.  The program
loops and never terminates.  The call to foo in main now has a choice point,
and there is always a new choice due to the asserted clause.

This actually happened to me yesterday.  What use is a debugger that introduces
new bugs?

Wayne Citrin
(ucbvax!citrin)