swipl-devel
swipl-devel copied to clipboard
A rare segfault while running tests
This is the first time I see this:
SWI Prolog 8.3.5 on Linux Fedora 30.
3/69 Test: swipl:core
Command: "swipl-devel_original/build/src/swipl" "-f" "none" "--no-packs" "-q" "swipl-devel_original/src/test.pl" "--no-core" "core"
Directory: swipl-devel_original/build/src
"swipl:core" start time: Aug 26 13:54 CEST
Output:
----------------------------------------------------------
Running scripts from core ........................................................................................................................................................................................................................................................................................................
SWI-Prolog [thread 6 () at Wed Aug 26 13:54:23 2020]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
[0] save_backtrace() at swipl-devel_original/build/../src/os/pl-cstack.c:332 [0x7fb780e5536e]
[1] print_c_backtrace() at swipl-devel_original/build/../src/os/pl-cstack.c:867 [0x7fb780e5550f]
[2] sigCrashHandler() at swipl-devel_original/build/../src/os/pl-cstack.c:905 [0x7fb780e55616]
[3] dispatch_signal() at swipl-devel_original/build/../src/pl-setup.c:546 [0x7fb780de2782]
[4] __restore_rt() at sigaction.c:? [0x7fb780b71ec0]
[5] visibleClause__LD() at swipl-devel_original/build/../src/pl-inline.h:479 [0x7fb780d6691a]
[6] nextClause__LD() at swipl-devel_original/build/../src/pl-index.c:586 [0x7fb780d69cb1]
[7] pl_retract1_va() at swipl-devel_original/build/../src/pl-proc.c:3039 [0x7fb780dce804]
[8] PL_next_solution() at swipl-devel_original/build/../src/pl-vmi.c:4012 [0x7fb780d8364c]
[9] callProlog() at swipl-devel_original/build/../src/pl-pro.c:391 [0x7fb780dc834d]
[10] start_thread() at swipl-devel_original/build/../src/pl-thread.c:1804 [0x7fb780df95ac]
[11] start_thread() at pthread_create.c:? [0x7fb780a194c0]
[12] __GI___clone() at :? [0x7fb780c36133]
Prolog stack:
[4264] system:retract/1 [PC=1 in supervisor]
[4263] plunit_retract:collect/2 [PC=8 in clause 1]
[1] plunit_retract:collect/1 [PC=7 in clause 1]
[0] system:$c_call_prolog/0 [PC=0 in top query clause]
Running on_halt hooks with status 139
Killing 14449 with default signal handlers
<end of output>
Test time = 4.22 sec
----------------------------------------------------------
Test Failed.
"swipl:core" end time: Aug 26 13:54 CEST
"swipl:core" time elapsed: 00:00:04
----------------------------------------------------------
Seems this (extracted) code:
:- dynamic a/1.
tc(N) :-
numlist(0, N, List),
sum_list(List, Sum),
forall(between(0, N, X),
assertz(a(X))),
thread_self(Me),
thread_create(collect(Me), Id1, []),
thread_create(collect(Me), Id2, []),
thread_join(Id1, true),
thread_join(Id2, true),
thread_get_message(collected(N1)),
thread_get_message(collected(N2)),
ConcurrentSum is N1+N2,
assertion(Sum == ConcurrentSum).
collect(Main) :-
collect(0, N),
thread_send_message(Main, collected(N)).
collect(N0, N) :-
retract(a(A)), !,
N1 is N0 + A,
collect(N1, N).
collect(N, N).
Tested now using this. Runs fine. Will run a bit longer and with more test instrumentation. Could in theory have suffered from the introduction of transactions.
?- forall(between(1, 1000, _), tc(10000)).