Closed TeamSPoon closed 1 week ago
Fixed
deb12user@GODLIKE:~$ mettalog
metta+>prolog.
[1 ?-
|
| lazy_findall(Res1,between(1,10,Res1),List1),
| lazy_findall(Res2,between(5,10,Res2),List2),
| member(E1,List1),member(E2,List2),E1=E2.
List1 = [1, 2, 3, 4, 5|_A],
List2 = [5|_B],
E1 = E2, E2 = 5,
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x5610945e0860), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x5610945e0860), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x5610945e0860), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x5610945e0860), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x5610945e0860), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x5610945e0860), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(3,0x561094e54250), 1), _A) .
well
2 ?-
| lazy_findall(Res1,between(1,10,Res1),List1),
lazy_findall(Res2,between(5,10,Res2),List2),
member(E1,List1),member(E2,List2),E1=E2.
List1 = [1, 2, 3, 4, 5|_A],
List2 = [5|_B],
E1 = E2, E2 = 5,
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x561094c1e650), 1), _A) ;
List1 = [1, 2, 3, 4, 5, 6|_A],
List2 = [5, 6|_B],
E1 = E2, E2 = 6,
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x561094c1e650), 1), _A) ;
List1 = [1, 2, 3, 4, 5, 6, 7|_A],
List2 = [5, 6, 7|_B],
E1 = E2, E2 = 7,
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x561094c1e650), 1), _A) ;
List1 = [1, 2, 3, 4, 5, 6, 7, 8|_A],
List2 = [5, 6, 7, 8|_B],
E1 = E2, E2 = 8,
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x561094c1e650), 1), _A) ;
List1 = [1, 2, 3, 4, 5, 6, 7, 8, 9|_A],
List2 = [5, 6, 7, 8, 9|_B],
E1 = E2, E2 = 9,
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x561094c1e650), 1), _A) ;
List1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10|_A],
List2 = [5, 6, 7, 8, 9, 10|_B],
E1 = E2, E2 = 10,
lazy_list(lazy_lists:lazy_engine_next(<engine>(5,0x561094cbc1e0), 1), _B),
lazy_list(lazy_lists:lazy_engine_next(<engine>(4,0x561094c1e650), 1), _A) ;
false.
There is a segmentation fault occurring in MeTTaLog when executing certain queries that involve lazy evaluation with
lazy_findall/3
in a multithreaded environment. It seems that a hook predicate might be undefined across different threads, leading to the crash when Prolog attempts to complain or raise an error, particularly in amessage_hook
.Reproduction Steps:
Run the following command using MeTTaLog:
Execute the following query:
Observations:
message_hook
but fails due to the missing predicate.Additional Information:
9.3.7-47-g1ff28598f-DIRTY
(development build).lazy_findall/3
.Expected Behavior:
Expected Behavior:
The expected behavior for this query when running directly in SWI-Prolog (without MeTTaLog) is as follows:
Actual Behavior:
The system crashes with a segmentation fault, making it impossible to diagnose the root cause through conventional error reporting mechanisms.
Suggested Fixes or Investigation Areas:
message_hook
handling to prevent crashes when an error message cannot be delivered.