Scryer-prolog: Memory overflows not caught

Created on 10 Apr 2018  路  6Comments  路  Source: mthom/scryer-prolog

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.

Most helpful comment

Please do not forget this one. It always takes some time to retest this...

All 6 comments

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:

https://github.com/rust-lang/rust/issues/48043

Was this page helpful?
0 / 5 - 0 ratings

Related issues

triska picture triska  路  4Comments

XVilka picture XVilka  路  3Comments

UWN picture UWN  路  3Comments

triska picture triska  路  3Comments

XVilka picture XVilka  路  3Comments