ulrich@p0:~/lftp/rusty-prolog$ ulimit -v 100000
ulrich@p0:~/lftp/rusty-prolog$ /opt/gupu/rusty-wam/target/debug/rusty-wam
prolog> a:-a,a.
prolog> ?-catch(a,error(E,_),true).
fatal runtime error: allocator memory exhausted
Illegal instruction (core dumped)
Expected (here, SICStus):
| ?- catch(a,error(E,_),true).
E = resource_error(memory) ?
yes
Instead of memory, some other atom may be used.
ulrich@p0:/opt/gupu/scryer-prolog$ /opt/gupu/scryer-prolog/target/debug/scryer-prolog
?- [user].
a:-a,a.
?- catch(a,error(E,_),true).
memory allocation of 92274688 bytes failed
Aborted (core dumped)
Please do not forget this one. It always takes some time to retest this...
It's tricky to do this in Rust. I still don't quite know how to approach it, even though some strides have been made with custom allocators recently.. I thought that meant it would be easier to detect allocation errors, but apparently not. I will continue to look into it.
All interesting bugs reside behind memory overflows. And it麓s important to handle these cases. After all, most programs are wrong in some initial stage
One thing that I do not understand is whether or not Rust can handle stackoverflows caused by recursion. If not, every routine has to be written with manual stack management.
Looks like there's a pending RFC to allow memory allocation errors to be caught:
Most helpful comment
Please do not forget this one. It always takes some time to retest this...