SWI-Prolog / swipl-devel

SWI-Prolog Main development repository
http://www.swi-prolog.org
Other
959 stars 175 forks source link

assignAttVar: Assertion failed #106

Closed triska closed 8 years ago

triska commented 8 years ago

Let sat3.pl consist of:

:- use_module(library(clpfd)).

sat(X) :- X in 0..9.

num(L) :-
    solve(As,Bs,Cs,Ds),
    append([As,Bs,Cs,Ds], Vs),
    findall(., labeling([ff], Vs), Ls),
    length(Ls, L).

solve([A1,A2,A3,A4],[B1,B2,B3,B4],[C1,C2,C3,C4],[D1,D2,D3,D4]) :-
    maplist(sat, [A1,A2,A3,A4,B1,B2,B3,B4,C1,C2,C3,C4,D1,D2,D3,D4]),
    A1 + A2 + A3 + A4 #= B1 + B2 + B3 + B4,
    A1 + A2 + A3 + A4 #= C1 + C2 + C3 + C4,
    A1 + A2 + A3 + A4 #= D1 + D2 + D3 + D4,
    A1 + A2 + A3 + A4 #= A1 + B1 + C1 + D1,
    A1 + B1 + C1 + D1 #= A2 + B2 + C2 + D2,
    A1 + B1 + C1 + D1 #= A3 + B3 + C3 + D3,
    A1 + B1 + C1 + D1 #= A4 + B4 + C4 + D4,
    A1 + A2 + A3 + A4 #= A1 + B2 + C3 + D4,
    A1 + B2 + C3 + D4 #= A4 + B3 + C2 + D1.

Then I get:

$ swipl -O sat3.pl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.15-7-gad4db9c)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- num(_).
[Thread 1 (main) at Mon Jan 18 19:59:27 2016] pl-attvar.c:174: assignAttVar: Assertion failed: (__PL_ld->stacks.global.top)+8 <= (__PL_ld->stacks.global.max) && (__PL_ld->stac
ks.trail.top)+6 <= (__PL_ld->stacks.trail.max)
C-stack trace labeled "assert_fail":
  [0] save_backtrace() at :? [0x7f6d261c484a]
  [1] __assert_fail() at ??:? [0x7f6d2618838a]
  [2] assignAttVar() at :? [0x7f6d2619375b]
  [3] pl_dattvar_assign2_va() at pl-attvar.c:? [0x7f6d26193871]
  [4] PL_next_solution() at ??:? [0x7f6d26128b37]
  [5] query_loop() at :? [0x7f6d2615d88e]
  [6] prologToplevel() at :? [0x7f6d2615e08b]
  [7] PL_toplevel() at ??:? [0x7f6d2611b1dd]
  [8] swipl(main+0x2d) [0x40083d]
  [9] __libc_start_main() at ??:? [0x7f6d25b47b45]
  [10] swipl(+0x881) [0x400881]

This is only reproducible with the -O flag, using Debian 8.1 (64-bit).

triska commented 8 years ago

Fixed by 900ec09f1c2ab9daeea41e5b786c82059f702304, many thanks!