scryer-prolog: Excessive memory usage in failure-driven loop
$ scryer-prolog --version "v0.8.123-557-gebe143d" $ scryer-prolog ?- use_module(library(between)). true. ?- [user]. q(E) :- X is 10^E, (between(1,X,_),false;true). ?- q(6). Segmentation fault (core dumped)
The issue with this is not the segmentation violation (or the catchability thereof as in issue #16).
It is the excessive amount of memory allocated before the segv happens.
What’s going on?
P.S. I defined q/1 to check if the problem was top-level related or not. It seems it does not.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 2
- Comments: 15 (8 by maintainers)
It would help here to issue a clean resource error. In this manner one could distinguish between copystack/global heap overflows and call stack/local stack overflows.
The variable isn’t needed. In this example the stack (local stack) is maybe growing but tail call optimization should have made this loop with constant memory.
@notoria Your example shows similarly erratic behavior. I can confirm that.
But the rest (why a
truemakes a difference) is quite puzzling to me…It should be the same issue.
length(_,_)uses memory for the list. So it is not a good example to draw conclusions from.@bakaq @UWN I cannot confirm this is fixed with the latest version.
Instead I find the following top-level query working fine:
But doing almost the same in an auxiliary predicate quickly runs out of memory:
This here works:
I can’t seem to reproduce this in the latest master. Memory usage doesn’t seem to scale with
Eat all, and there is no SEGV at least untilE = 8(it takes exponentially more time to increase it further, as expected).