trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
252 stars 11 forks source link

CLPZ: `#<==>/2` crashing (and consequently: `clpz_t/2`, `#=/3`, `#</3`) #522

Closed haijinSk closed 2 months ago

haijinSk commented 2 months ago

On Ubuntu using a binary release version "v2.50.20" (not the first release/version with this behavior).

Examples with clpz library already loaded.

Crashing:

?- 4 #= 4 #<==> #B.
realloc(): invalid next size
Aborted (core dumped)

By the way, no crash if # is removed from the #B:

?- 4 #= 4 #<==> B.
   B = 1. % as expected

But the "removed #" case is crashing with a variable in the left expression:

?- X #= 4 #<==> B.
realloc(): invalid next size
Aborted (core dumped)

Thank you.

infradig commented 2 months ago

I can't replicate this one.

flexoron commented 2 months ago

$ git clone ... && cd trealla $ make $ tpl -v Trealla Prolog (c) Infradig 2020-2023, v2.50.21

$ tpl
?- use_module(library(clpz)).
   true.
?- 4 #= 4 #<==> #B.
free(): corrupted unsorted chunks
Aborted (core dumped)

$ tpl
?- use_module(library(clpz)).
   true.
?- 4 #= 4 #<==> B.
   B = 1.

?- X #= 4 #<==> B.
free(): invalid pointer
Aborted (core dumped)

I get other core-dump messages.

infradig commented 2 months ago

Yeah, my bad.

On Sun, Apr 14, 2024 at 9:13 AM flexoron @.***> wrote:

$ git clone ... && cd trealla $ make $ tpl -v Trealla Prolog (c) Infradig 2020-2023, v2.50.21

$ tpl ?- use_module(library(clpz)). true. ?- 4 #= 4 #<==> #B. free(): corrupted unsorted chunks Aborted (core dumped)

$ tpl ?- use_module(library(clpz)). true. ?- 4 #= 4 #<==> B. B = 1.

?- X #= 4 #<==> B. free(): invalid pointer Aborted (core dumped)

I get other core-dump messages.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/522#issuecomment-2053791759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSESSZZLY5GX4MMTY5ITY5G32TAVCNFSM6AAAAABGFRGW4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJTG44TCNZVHE . You are receiving this because you commented.Message ID: @.***>

haijinSk commented 2 months ago

I thought, my hope was, that if the (#<==>)/2 examples will work, the (#=)/3 and (#<)/3will work, not crashing. Now, in v2.50.23b, my (#<==>)/2 examples here work. Now (v2.50.23b), the (#=)/3 and (#<)/3 work, thank you; unfortunately they work only in isolation.

Used in tfilter/3 from reif library, or in maplist/3, they are still crashing.

In isolation as expected:

?- #=(1,1,B).
   B = true.
?- #<(1,2,B).
   B = true.

But crashing if used in the metapredicate:

?- maplist(#=(3),[1,2,3],Bs).
realloc(): invalid next size
Aborted (core dumped)

?- maplist(#<(3),[1,2,3],Bs).
realloc(): invalid next size
Aborted (core dumped)
infradig commented 2 months ago

Ok, great, that's really useful. It seems somewhere in atts it's expanding the slots improperly.

On Sun, Apr 14, 2024 at 6:06 PM Peter @.***> wrote:

I thought, my hope was, that if the (#<==>)/2 examples will work, the (

=)/3 and (#<)/3 will work, not crashing. Now, in v2.50.23b my #<==>/2

examples here work. The #=/3 and #</3 work, thank you; unfortunately they work only in isolation.

But as a predicate of metapredicate, with tfilter/3 from reif library, or with maplist/3 they are still crashing.

In isolation as expected:

?- #=(1,1,B). B = true. ?- #<(1,2,B). B = true.

But crashing if used in a metapredicate:

?- maplist(#=(3),[1,2,3],Bs). realloc(): invalid next size Aborted (core dumped)

?- maplist(#<(3),[1,2,3],Bs). realloc(): invalid next size Aborted (core dumped)

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/522#issuecomment-2053956109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSERYFK554WFJAZOWFYTY5I2IRAVCNFSM6AAAAABGFRGW4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJTHE2TMMJQHE . You are receiving this because you commented.Message ID: @.***>

haijinSk commented 2 months ago

v2.50.26, no crash, the examples work; thank you!