Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycle detection panic #2632

Open
dcnorris opened this issue Oct 21, 2024 · 3 comments
Open

Cycle detection panic #2632

dcnorris opened this issue Oct 21, 2024 · 3 comments

Comments

@dcnorris
Copy link

% Repro for cycle detection crash
:- use_module(library(lists)).
:- use_module(library(clpz)).
:- use_module(library(error)).
:- use_module(library(lambda)).
:- use_module(library(debug)).

clpz:monotonic.

q_r(T/N, T:U) :- 0 #=< #T, 0 #=< #U, #N #= T + U.

qs_Ts_Us(Qs, ΣTs, ΣUs) :-
    maplist(\Q^T^U^(q_r(Q, T:U)), Qs, Ts, Us),
    intlist_partsums(Ts, ΣTs),
    intlist_partsums(Us, ΣUs).

%% Utility predicates used above:

intlist_partsums([X|Xs], [X|Ss]) :-
    intlist_partsums_acc(Xs, Ss, X).

intlist_partsums_acc([], [], _).
intlist_partsums_acc([X|Xs], [S|Ss], A) :-
    #S #= #X + #A,
    intlist_partsums_acc(Xs, Ss, S).

%?- qs_Ts_Us([1/6,2/6], Ts, Us).
%@    Ts = [1,3], Us = [5,9].

%?- qs_Ts_Us(Qs, [1,3], [5,9]).
%@ thread 'main' panicked at src/machine/cycle_detection.rs:136:36:
%@ index out of bounds: the len is 3818 but the index is 3824
%@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
%@ thread 'main' panicked at src/machine/cycle_detection.rs:136:36:
%@ index out of bounds: the len is 3818 but the index is 3824
%@ stack backtrace:
%@    0:     0x561cf9a2f5da - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b9dad2a88e955ff
%@    1:     0x561cf9560a0b - core::fmt::write::h4b5a1270214bc4a7
%@    2:     0x561cf99fb842 - std::io::Write::write_fmt::hd04af345a50c312d
%@    3:     0x561cf9a340d7 - std::panicking::default_hook::{{closure}}::h96ab15e9936be7ed
%@    4:     0x561cf9a3532c - std::panicking::rust_panic_with_hook::hfe205f6954b2c97b
%@    5:     0x561cf9a34b75 - std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44
%@    6:     0x561cf9a34ad9 - std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e
%@    7:     0x561cf9a34ac4 - rust_begin_unwind
%@    8:     0x561cf952d832 - core::panicking::panic_fmt::h3d8fc78294164da7
%@    9:     0x561cf952d916 - core::panicking::panic_bounds_check::h9397cb495d89a72d
%@   10:     0x561cf99f1e40 - scryer_prolog::machine::cycle_detection::CycleDetectingIter<_>::forward::h41d544dab73e1906
%@   11:     0x561cf99f2ebb - <scryer_prolog::machine::cycle_detection::CycleDetectingIter<_> as core::ops::drop::Drop>::drop::h245dc4614de9f3a9
%@   12:     0x561cf9800a16 - scryer_prolog::machine::machine_state_impl::<impl scryer_prolog::machine::machine_state::MachineState>::is_cyclic_term::h7ef087563dffeeb6
%@   13:     0x561cf9772722 - scryer_prolog::machine::Machine::run_module_predicate::he473b7cf1b8e2631
%@   14:     0x561cf9994fcf - scryer_prolog::run_binary::h14ffeeed078e5466
%@   15:     0x561cf954fc23 - std::sys::backtrace::__rust_begin_short_backtrace::h41e2c81a136bd572
%@   16:     0x561cf9550022 - main
%@   17:     0x7ff9bfe4624a - __libc_start_call_main
%@                                at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
%@   18:     0x7ff9bfe46305 - __libc_start_main_impl
%@                                at ./csu/../csu/libc-start.c:360:3
%@   19:     0x561cf954fb51 - _start
%@   20:                0x0 - <unknown>
%@ thread 'main' panicked at library/core/src/panicking.rs:229:5:
%@ panic in a destructor during cleanup
%@ thread caused non-unwinding panic. aborting.
@UWN
Copy link

UWN commented Oct 21, 2024

With rebis-dev I had to add

:- initialization(asserta(clpz:monotonic)).

(The fact alone was not permitted)

?- qs_Ts_Us(Qs, [1,3], [5,9]).
   error(type_error(integer,clpz(clpz_attr(no,no,no,from_to(n(0),sup),fd_props([],[propagator(pplus(_928425,_928427,_928429,_928424),_928419)],[]),queue(_928409,_928410,_928411,_928412)))),must_be/2).

@notoria
Copy link
Contributor

notoria commented Dec 17, 2024

This is a mis-compilation error:

intlist_partsums([X|Xs], [X|Ss]) :-
    true,
    intlist_partsums_acc(Xs, Ss, X).

It works with this change.

@bakaq
Copy link
Contributor

bakaq commented Dec 17, 2024

Possibly related to #2706?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants