trealla: getting corrupted double-linked list

We are getting a corrupted double-linked list:

cd /tmp
git clone https://github.com/eyereasoner/eye2
cd eye2
git checkout tags/v1.1.2
tpl -g main eye3.pl etc/lee.pl
:- op(1150,xfx,=>).

'urn:example:route'([[1,1],[9,8],[[[2,3],[4,5]],[[6,6],[8,8]]]],[[9,8],[9,7],[9,6],[9,5],[8,5],[7,5],[6,5],[5,5],[5,4],[5,3],[5,2],[4,2],[3,2],[2,2],[1,2],[1,1]]) => true.
corrupted double-linked list
Aborted

It also occurs in 7 of our other examples and test cases:

cd etc
./test
----------------
Running eye3 etc
eye3 v1.1.2
trealla v2.60.18
----------------

ackermann.pl            corrupted double-linked list
../eye3: line 4: 80437 Aborted                 tpl -g main ${EYE3} "$@"
    726 msec OK
acp.pl                      101 msec OK
bmt.pl                     1419 msec OK
complex.pl              corrupted double-linked list
../eye3: line 4: 80473 Aborted                 tpl -g main ${EYE3} "$@"
     85 msec OK
control.pl                   77 msec OK
dt.pl                      1694 msec OK
easter.pl               corrupted double-linked list
../eye3: line 4: 80509 Aborted                 tpl -g main ${EYE3} "$@"
     82 msec OK
eulers-identity.pl           77 msec OK
fibonacci.pl                 84 msec OK
fourcolor.pl                 84 msec OK
fuse.pl                      77 msec OK
good-cobbler.pl              75 msec OK
gps.pl                  corrupted double-linked list
../eye3: line 4: 80581 Aborted                 tpl -g main ${EYE3} "$@"
     80 msec OK
graph.pl                corrupted double-linked list
../eye3: line 4: 80593 Aborted                 tpl -g main ${EYE3} "$@"
     89 msec OK
hanoi.pl                     93 msec OK
lee.pl                  corrupted double-linked list
../eye3: line 4: 80617 Aborted                 tpl -g main ${EYE3} "$@"
     80 msec OK
mi.pl                        76 msec OK
polygon.pl                   72 msec OK
polynomial.pl                91 msec OK
sdcoding.pl             corrupted double-linked list
../eye3: line 4: 80665 Aborted                 tpl -g main ${EYE3} "$@"
     79 msec OK
socrates.pl                  76 msec OK
sudoku.pl               corrupted double-linked list
../eye3: line 4: 80689 Aborted                 tpl -g main ${EYE3} "$@"
   1017 msec OK
tak.pl                      879 msec OK
turing.pl                    93 msec OK
workplace-benchmark.pl     2443 msec OK
workplace.pl                 73 msec OK

10 sec 26 OK 0 FAILED

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Well ChatGPT was right, it just didn’t know that catch/3 was to blame.

Thanks, it looks better now for sure. Trace thing still happens but maybe unrelated.

I’m going with this fix. It just introduces a single small memory leak on initialization goals. I’ll look into it again tomorrow.

Not sure if this is helpful, but another snippet that triggers a similar invalid read:

:- use_module(library(clpz)).

test(X) :-
    Y mod 100 #= 0,
    X #= Y.
?- test(X).
   clpz:(X mod 100#=0).
==2299== Invalid read of size 8
==2299==    at 0x2A6B70: __aarch64_ldadd8_acq_rel (in /Users/guregu/code/trealla/trealla/tpl)
==2299==    by 0x28264B: unshare_cell_ (internal.h:927)
==2299==    by 0x28B603: query_destroy (query.c:1808)
==2299==    by 0x26072F: run (parser.c:4174)
==2299==    by 0x27ED5F: pl_eval (prolog.c:145)
==2299==    by 0x118D1F: main (tpl.c:378)
==2299==  Address 0x643b640 is 0 bytes inside a block of size 41 free'd
==2299==    at 0x4887B60: free (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==2299==    by 0x28266B: unshare_cell_ (internal.h:928)
==2299==    by 0x28B603: query_destroy (query.c:1808)
==2299==    by 0x26072F: run (parser.c:4174)
==2299==    by 0x27ED5F: pl_eval (prolog.c:145)
==2299==    by 0x118D1F: main (tpl.c:378)
==2299==  Block was alloc'd at
==2299==    at 0x48850E8: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-arm64-linux.so)
==2299==    by 0x248ABF: make_string_internal (parser.c:122)
==2299==    by 0x25FC0B: tokenize (parser.c:4076)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299==    by 0x25D0AF: tokenize (parser.c:3635)
==2299== 

It is!