?- gtrace, append(L1,L2,[1,2,3]). crash after first answer is shown

I am using SWI-Prolog version 8.1.26 under macOS 14 (Mojave).

?- gtrace, append(L1,L2,[1,2,3]).    

shows me the first solution, but when I type ‘;’ to see the next answer,
the graphical debugger and the interpreter process crash.

The same happened under Parallels Desktops Windows.

However, e.g.

?- gtrace, member(M,[1,2,3]).

works as expected.

2 Likes

Exactly the same with

SWI-Prolog (threaded, 64 bits, version 8.1.32-171-g4ba05b1cc) on Windows 10 and today’s daily build
SWI-Prolog (threaded, 64 bits, version 8.3.0-172-g5e86d749d)

Did not test with Parallels Desktops Windows as I do not run a Mac.


When running with WSL 2 using SWI-Prolog (threaded, 64 bits, version 8.1.32) on Ubuntu 18.04 LTS and XWindows running on Windows 10

?- gtrace,append(L1,L2,[1,2,3]).
% The graphical front-end will be used for subsequent tracing
L1 = [],
L2 = [1, 2, 3] ;

SWI-Prolog [thread 1 (main) at Tue Jun  2 16:24:59 2020]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
  [0] PL_strtod() at ??:? [0x7fcd9795a4b8]
  [1] bstore_print_backtrace_named() at ??:? [0x7fcd9795a66e]
  [2] bstore_print_backtrace_named() at ??:? [0x7fcd9795a78f]
  [3] PL_get_signum_ex() at ??:? [0x7fcd978e8853]
  [4] killpg() at ??:? [0x7fcd97491f20]
  [5] pl_filled_array4_va() at ??:? [0x7fcd978c7efd]
  [6] pl_filled_array4_va() at ??:? [0x7fcd978c86c9]
  [7] pl_filled_array4_va() at ??:? [0x7fcd978c8848]
  [8] PL_next_solution() at ??:? [0x7fcd978819bf]
  [9] PL_call_predicate() at ??:? [0x7fcd97890c3d]
  [10] pl_pce_init() at ??:? [0x7fcd9528adae]
  [11] pl_pce_init() at ??:? [0x7fcd9528ae40]
  [12] PL_next_solution() at ??:? [0x7fcd978818ed]
  [13] pl_skip_list3_va() at ??:? [0x7fcd978ce2cf]
  [14] pl_skip_list3_va() at ??:? [0x7fcd978ce50b]
  [15] PL_next_solution() at ??:? [0x7fcd978819bf]
  [16] PL_interrupt() at ??:? [0x7fcd978ee910]
  [17] PL_next_solution() at ??:? [0x7fcd9788d1d3]
  [18] pl_skip_list3_va() at ??:? [0x7fcd978cddb4]
  [19] pl_skip_list3_va() at ??:? [0x7fcd978ce65b]
  [20] PL_toplevel() at ??:? [0x7fcd9787a5dd]
  [21] swipl(+0x7c5) [0x55ea01aed7c5]
  [22] __libc_start_main() at ??:? [0x7fcd97474b97]
  [23] swipl(+0x80a) [0x55ea01aed80a]
Prolog stack:
  [38] system:term_attvars/2 [PC=1 in supervisor]
  [37] $attvar:copy_term/3 [PC=6 in clause 1]
  [36] pce_principal:send_implementation/3 [PC=36 in clause 150]
  [35] system:$c_call_prolog/0 [PC=0 in top query clause]
  [34] pce_principal:send/2 <foreign>
  [33] pce_prolog_tracer:show_bindings/2 [PC=200 in clause 1]
  [32] pce_prolog_tracer:prolog_show_frame/2 [PC=26 in clause 1]
  [30] pce_prolog_tracer:show/4 [PC=10 in clause 2]
  [29] pce_prolog_tracer:do_intercept_/4 [PC=26 in clause 5]
  [28] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [24] pce_prolog_tracer:intercept_/4 [PC=48 in clause 1]
  [23] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [19] system:$c_call_prolog/0 [PC=0 in top query clause]
  [18] system:notrace/1 <foreign>
  [17] pce_prolog_tracer:prolog_trace_interception_gui/4 [PC=23 in clause 1]
  [16] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [12] system:$c_call_prolog/0 [PC=0 in top query clause]
  [11] lists:append/3 [PC=-1 in clause 2]
  [10] system:<meta-call>/1 [PC=8 in clause -1]
  [9] $toplevel:toplevel_call/1 [PC=3 in clause 1]
  [8] $toplevel:stop_backtrace/1 [PC=4 in clause 1]
  [7] $tabling:$wfs_call/2 [PC=17 in clause 1]
  [6] $toplevel:residue_vars/3 [PC=11 in clause 2]
  [5] $toplevel:$execute_goal2/3 [PC=29 in clause 1]
  [3] $toplevel:$query_loop/0 [PC=39 in clause 2]
Running on_halt hooks with status 139
Killing 13828 with default signal handlers
Segmentation fault

HTH

I can get it to crashh too, but only if I step through the debugger the first time:

Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.0-8-g80f40cdea-DIRTY)
2 ?- gtrace, append(L1,L2,[1,2,3]).  % just pressing 'n' in the debugger
% The graphical front-end will be used for subsequent tracing
L1 = [],
L2 = [1, 2, 3] ;
L1 = [1],
L2 = [2, 3] ;
L1 = [1, 2],
L2 = [3] ;
L1 = [1, 2, 3],
L2 = [] ;
false.

3 ?- gtrace, append(L1,L2,[1,2,3]).  % Pressing <space> and ;
L1 = [],
L2 = [1, 2, 3] ;

SWI-Prolog [thread 1 (main) at Tue Jun  2 16:01:50 2020]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
  [0] save_backtrace() at /home/u/tmp/swipl-devel/build.release/../src/os/pl-cstack.c:332 [0x7f32202c9b01]
  [1] print_c_backtrace() at /home/u/tmp/swipl-devel/build.release/../src/os/pl-cstack.c:867 [0x7f32202c9d5c]
  [2] sigCrashHandler() at /home/u/tmp/swipl-devel/build.release/../src/os/pl-cstack.c:905 [0x7f32202c9e96]
  [3] dispatch_signal() at /home/u/tmp/swipl-devel/build.release/../src/pl-setup.c:545 [0x7f32202531dd]
  [4] __restore_rt() at sigaction.c:? [0x7f322001b3e0]
  [5] term_variables_loop() at /home/u/tmp/swipl-devel/build.release/../src/pl-prims.c:2988 [0x7f322023102c]
  [6] term_variables() at /home/u/tmp/swipl-devel/build.release/../src/pl-prims.c:3065 [0x7f32202317b6]
  [7] pl_term_attvars2_va() at /home/u/tmp/swipl-devel/build.release/../src/pl-prims.c:3127 [0x7f3220231928]
  [8] PL_next_solution() at /home/u/tmp/swipl-devel/build.release/../src/pl-vmi.c:3810 [0x7f32201ec467]
  [9] PL_call_predicate() at /home/u/tmp/swipl-devel/build.release/../src/pl-fli.c:4146 [0x7f32201f8658]
  [10] invoke() at /home/u/tmp/swipl-devel/build.release/../packages/xpce/swipl/interface.c:2148 [0x7f321ed843cb]
  [11] pl_send() at /home/u/tmp/swipl-devel/build.release/../packages/xpce/swipl/interface.c:2215 [0x7f321ed84480]
  [12] PL_next_solution() at /home/u/tmp/swipl-devel/build.release/../src/pl-vmi.c:3844 [0x7f32201ec39c]
  [13] callProlog() at /home/u/tmp/swipl-devel/build.release/../src/pl-pro.c:391 [0x7f3220237316]
  [14] pl_notrace1_va() at /home/u/tmp/swipl-devel/build.release/../src/pl-pro.c:268 [0x7f322023759b]
  [15] PL_next_solution() at /home/u/tmp/swipl-devel/build.release/../src/pl-vmi.c:3810 [0x7f32201ec467]
  [16] traceInterception() at /home/u/tmp/swipl-devel/build.release/../src/pl-trace.c:1239 [0x7f3220258b0b]
  [17] PL_next_solution() at /home/u/tmp/swipl-devel/build.release/../src/pl-wam.c:3299 [0x7f32201eef75]
  [18] query_loop() at /home/u/tmp/swipl-devel/build.release/../src/pl-pro.c:144 [0x7f3220236e8f]
  [19] prologToplevel() at /home/u/tmp/swipl-devel/build.release/../src/pl-pro.c:483 [0x7f32202376fb]
  [20] PL_toplevel() at /home/u/tmp/swipl-devel/build.release/../src/pl-fli.c:4586 [0x7f32201e0e4e]
  [21] swipl(+0x10a5) [0x5592020660a5]
  [22] __libc_start_main() at ??:? [0x7f3220006002]
  [23] swipl(+0x10ee) [0x5592020660ee]
Prolog stack:
  [38] system:term_attvars/2 [PC=1 in supervisor]
  [37] $attvar:copy_term/3 [PC=6 in clause 1]
  [36] pce_principal:send_implementation/3 [PC=36 in clause 150]
  [35] system:$c_call_prolog/0 [PC=0 in top query clause]
  [34] pce_principal:send/2 <foreign>
  [33] pce_prolog_tracer:show_bindings/2 [PC=200 in clause 1]
  [32] pce_prolog_tracer:prolog_show_frame/2 [PC=26 in clause 1]
  [30] pce_prolog_tracer:show/4 [PC=10 in clause 2]
  [29] pce_prolog_tracer:do_intercept_/4 [PC=26 in clause 5]
  [28] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [24] pce_prolog_tracer:intercept_/4 [PC=48 in clause 1]
  [23] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [19] system:$c_call_prolog/0 [PC=0 in top query clause]
  [18] system:notrace/1 <foreign>
  [17] pce_prolog_tracer:prolog_trace_interception_gui/4 [PC=23 in clause 1]
  [16] system:setup_call_catcher_cleanup/4 [PC=5 in clause 1]
  [12] system:$c_call_prolog/0 [PC=0 in top query clause]
  [11] lists:append/3 [PC=-1 in clause 2]
  [10] system:<meta-call>/1 [PC=8 in clause -1]
  [9] $toplevel:toplevel_call/1 [PC=3 in clause 1]
  [8] $toplevel:stop_backtrace/1 [PC=4 in clause 1]
  [7] $tabling:$wfs_call/2 [PC=17 in clause 1]
  [5] $toplevel:$execute_goal2/3 [PC=29 in clause 1]
  [3] $toplevel:$query_loop/0 [PC=39 in clause 2]
  [2] $toplevel:$runtoplevel/0 [PC=19 in clause 1]
Running on_halt hooks with status 139
Killing 663742 with default signal handlers
[2]    663742 segmentation fault (core dumped)  swipl

Also crashes on Ubuntu 18.04 with SWI-Prolog 8.3.0 (installed from the “dev” PPA).

Reproduces fine. Thanks for reporting. Bottom line is a Prolog stack corruption. The sad thing is that when I enable all internal consistency checks to get as close as possible to the step that causes the corruption, the problem vanishes :frowning: Probably for tomorrow …

1 Like

Found and fixed in both stable and devel git versions. Bottom line is that getting the local variables for the source level debugger could fetch uninitialized variables after backtracking to the next clause. This issue only affects the graphical debugger.

2 Likes