The following program raises a failed assertion in the last SWI-Prolog stable version (and several older ones), but do not in version 7.6.4:
% Run: swipl -q -s swi_stream_assertion_reproducer.pl
% This program opens its own source for reading.
% Observed on Windows 10 and 11: SWI-Prolog 10.0.2 and 9.2.9 abort with
% "Assertion failed: ref->read->references" in src/os/pl-file.c.
% SWI-Prolog 7.6.4 completes and prints "done".
:- initialization(main, main).
main :-
source_file(main, File),
forall(between(1, 20, N),
( format(user_error, 'iteration \~d\~n', \[N\]),
open(File, read, Input),
set_input(Input),
seen,
stream_property(Stream, alias(user_input)),
(stream_property(Stream, file_name(\_)) -> true ; true)
)),
writeln(done).
This is a minimal program that reproduces (thanks to GPT Terra 6.1) what happens in DES, which is why it still relies on that old SWI-Prolog version.