Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical Debugger Crashes #28

Open
samwalrus opened this issue Oct 17, 2015 · 4 comments
Open

Graphical Debugger Crashes #28

samwalrus opened this issue Oct 17, 2015 · 4 comments

Comments

@samwalrus
Copy link

Using SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.9) Ubuntu
When trying to graphically debug a program prolog crashes.
The query is:
?- gen_arcs(1,[0,1],T), maplist(sep,T,Arcs,_).

The error:
[trace] ?- gen_arcs(1,[0,1],T), maplist(sep,T,Arcs,_).
T = [t(arc(1, 0, 1), [1, 0, 1])],
Arcs = [arc(1, 0, 1)] ;
T = [t(arc(1, 1, 1), [1, 1, 1])],
Arcs = [arc(1, 1, 1)] ;
[Thread 1 (main) at Sat Oct 17 18:39:46 2015] pl-write.c:1040: writePrimitive: Assertion failed: 0
C-stack trace labeled "assert_fail":
[0] PL_strtod() at ??:? [0x7fc33e48d7f0]
[1] __assert_fail() at ??:? [0x7fc33e4522c1]
[2] destroyXR() at ??:? [0x7fc33e44d489]
[3] destroyXR() at ??:? [0x7fc33e44dc7b]
[4] destroyXR() at ??:? [0x7fc33e44e340]
[5] destroyXR() at ??:? [0x7fc33e44f250]
[6] utf8_strncmp() at ??:? [0x7fc33e486c01]
[7] PL_next_solution() at ??:? [0x7fc33e3e9145]
[8] PL_call_predicate() at ??:? [0x7fc33e3f23bc]
[9] pl_pce_init() at ??:? [0x7fc33c513b0d]
[10] pl_pce_init() at ??:? [0x7fc33c513b90]
[11] PL_next_solution() at ??:? [0x7fc33e3e917f]
[12] PL_call_predicate() at ??:? [0x7fc33e3f23bc]
[13] pl_pce_init() at ??:? [0x7fc33c513b0d]
[14] pl_pce_init() at ??:? [0x7fc33c513b90]
[15] PL_next_solution() at ??:? [0x7fc33e3e917f]
[16] pl_skip_list3_va() at ??:? [0x7fc33e425fa3]
[17] pl_skip_list3_va() at ??:? [0x7fc33e42615d]
[18] PL_next_solution() at ??:? [0x7fc33e3e9248]
[19] PL_interrupt() at ??:? [0x7fc33e4440c4]
[20] PL_interrupt() at ??:? [0x7fc33e443b63]
[21] PL_next_solution() at ??:? [0x7fc33e3f06e4]
[22] pl_skip_list3_va() at ??:? [0x7fc33e425b2e]
[23] pl_skip_list3_va() at ??:? [0x7fc33e4262b0]
[24] PL_toplevel() at ??:? [0x7fc33e3e314d]
[25] prolog(main+0x2d) [0x40083d]
[26] __libc_start_main() at /build/buildd/eglibc-2.19/csu/libc-start.c:321 [0x7fc33ddf5ec5]
[27] prolog(+0x881) [0x400881]
Aborted (core dumped)

The program is:

:-use_module(library(clpfd)).

fd_length(L, N) :-
   N #>= 0,
   fd_length(L, N, 0).

fd_length([], N, N0) :-
   N #= N0.
fd_length([_|L], N, N0) :-
   N1 is N0+1,
   N #>= N1,
   fd_length(L, N, N1).

equal_truth(X, Y, R) :- X == Y, !, R = true.
equal_truth(X, Y, R) :- ?=(X, Y), !, R = false. % syntactically different
equal_truth(X, Y, R) :- X \= Y, !, R = false. % semantically different
equal_truth(X, Y, R) :- R == true, !, X = Y.
equal_truth(X, X, true).
equal_truth(X, Y, false) :-
   dif(X, Y).

=(X, Y, T) :-
  equal_truth(X, Y, T).

if_( C_1, Then_0, Else_0) :-
   call(C_1, Truth),
   functor(Truth,_,0),  % safety check
   ( Truth == true -> Then_0 ; Truth == false, Else_0 ).

list_memberd_t([]    ,_,false).
list_memberd_t([Y|Ys],X,Truth) :-
   if_(X=Y, Truth=true, list_memberd_t(Ys,X,Truth)).

memberd_t(X,Xs,Truth) :- list_memberd_t(Xs,X,Truth).

list_memberd_truth(Xs,X,Truth) :- list_memberd_t(Xs,X,Truth).

gen_arcs(MaxNodes,Language,Arcs):-
    append([Min|_],[Max],Language),
    Arc_Label in Min..Max,
    Arcs=[t(arc(X,Arc_Label,Z),[X,Arc_Label,Z])],
    [X,Z] ins 1..MaxNodes,
    1 #= min(X,Z),
    label([X,Z]),
    label([Arc_Label]).

gen_arcs(Max_Nodes,Language,[t(arc(X,Arc_Label,Z),[X,Arc_Label,Z])|TArcs]):-
    append([Min|_],[Max],Language),
    Arc_Label in Min..Max,
    gen_arcs(Max_Nodes,Language,TArcs),
    maplist(sep,TArcs,Arcs,_),
    chain([EX,EZ,X,Z],#>=),
    label([Arc_Label]),
    [X,Z] ins 1..Max_Nodes,
    label([X,Z]),
    memberd_t(arc(X,Arc_Label,Z),Arcs,false),
    memberd_t(arc(EX,_,EZ),Arcs,true).

combined_arcs_vars(Combined,Arcs,Vars):-
    maplist(sep,Combined,Arcs,Vars).

sep(t(Arc,Var),Arc,Var).
sep2(arc(Node1,Edge,Node2),Node1,Edge,Node2).
@JanWielemaker
Copy link
Member

The program contains syntax errors in at least two places and you give no clue how you
start the trace session. Without details I cannot reproduce this.

@samwalrus
Copy link
Author

I don't know what the syntax errors are, prolog does does not give any errors when loading the file. I am trying to debug the program as I know it does not work.

I just load the file from the command line:
prolog -s 'my_file.pl'

Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.9)
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).

?- gtrace.
% The graphical front-end will be used for subsequent tracing
true.

[trace] ?- gen_arcs(1,[0,1],T), maplist(sep,T,Arcs,_).
T = [t(arc(1, 0, 1), [1, 0, 1])],
Arcs = [arc(1, 0, 1)] ;
T = [t(arc(1, 1, 1), [1, 1, 1])],
Arcs = [arc(1, 1, 1)] ;
T = [t(arc(1, 1, 1), [1, 1, 1]), t(arc(1, 0, 1), [1, 0, 1])],
Arcs = [arc(1, 1, 1), arc(1, 0, 1)] ;
T = [t(arc(1, 0, 1), [1, 0, 1]), t(arc(1, 1, 1), [1, 1, 1])],
Arcs = [arc(1, 0, 1), arc(1, 1, 1)] ;

at this point the system hangs and I abort by pressing ctrl-c a I then try the goal again:

[trace] ?- gen_arcs(1,[0,1],T), maplist(sep,T,Arcs,_).
T = [t(arc(1, 0, 1), [1, 0, 1])],
Arcs = [arc(1, 0, 1)] ;
T = [t(arc(1, 1, 1), [1, 1, 1])],
Arcs = [arc(1, 1, 1)] ;
[Thread 1 (main) at Sun Oct 18 09:52:00 2015] pl-write.c:1040: writePrimitive: Assertion failed: 0
C-stack trace labeled "assert_fail":
[0] PL_strtod() at ??:? [0x7f9ca7a097f0]
[1] __assert_fail() at ??:? [0x7f9ca79ce2c1]
[2] destroyXR() at ??:? [0x7f9ca79c9489]
[3] destroyXR() at ??:? [0x7f9ca79c9c7b]
[4] destroyXR() at ??:? [0x7f9ca79ca340]
[5] destroyXR() at ??:? [0x7f9ca79cb250]
[6] utf8_strncmp() at ??:? [0x7f9ca7a02c01]
[7] PL_next_solution() at ??:? [0x7f9ca7965145]
[8] PL_call_predicate() at ??:? [0x7f9ca796e3bc]
[9] pl_pce_init() at ??:? [0x7f9ca5a8fb0d]
[10] pl_pce_init() at ??:? [0x7f9ca5a8fb90]
[11] PL_next_solution() at ??:? [0x7f9ca796517f]
[12] PL_call_predicate() at ??:? [0x7f9ca796e3bc]
[13] pl_pce_init() at ??:? [0x7f9ca5a8fb0d]
[14] pl_pce_init() at ??:? [0x7f9ca5a8fb90]
[15] PL_next_solution() at ??:? [0x7f9ca796517f]
[16] pl_skip_list3_va() at ??:? [0x7f9ca79a1fa3]
[17] pl_skip_list3_va() at ??:? [0x7f9ca79a215d]
[18] PL_next_solution() at ??:? [0x7f9ca7965248]
[19] PL_interrupt() at ??:? [0x7f9ca79c00c4]
[20] PL_interrupt() at ??:? [0x7f9ca79bfb63]
[21] PL_next_solution() at ??:? [0x7f9ca796c6e4]
[22] pl_skip_list3_va() at ??:? [0x7f9ca79a1b2e]
[23] pl_skip_list3_va() at ??:? [0x7f9ca79a22b0]
[24] PL_toplevel() at ??:? [0x7f9ca795f14d]
[25] prolog(main+0x2d) [0x40083d]
[26] __libc_start_main() at /build/buildd/eglibc-2.19/csu/libc-start.c:321 [0x7f9ca7371ec5]
[27] prolog(+0x881) [0x400881]
Aborted (core dumped)

@JanWielemaker
Copy link
Member

Ah. It is GitHub's wiki syntax that breaks the program ... Added .... around it and now the program is readable and syntactically correct. The abort is a quite vital piece of the info. With
that it reproduces (at least one time) I'll have a look. The required interaction might make it a
little hard to track :(

@JanWielemaker JanWielemaker reopened this Oct 18, 2015
@JanWielemaker
Copy link
Member

Hmm. I found two bugs in the gui tracer, but I'm unsure whether or not this particular one is fixed. You may want to try the latest git version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants