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

Resource error cannot be caught #246

Open
UWN opened this issue Jul 8, 2023 · 8 comments
Open

Resource error cannot be caught #246

UWN opened this issue Jul 8, 2023 · 8 comments

Comments

@UWN
Copy link

UWN commented Jul 8, 2023

?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;   error(resource_error(memory),true/0), unexpected.
   ...
;  I = 4, N = 65536, Err = error(resource_error(_),_)  % expected, but not found
;  I = 5, N = 4294967296, Err = error(resource_error(_),_)  % expected, but not found
;  ... .
@UWN
Copy link
Author

UWN commented Jul 9, 2023

Now two observations:

After the first answer, I type a for all. But only all answers are produced up to the first resource error. Typing a again gives me only the next answer. This until I get the following error:

?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 4, N = 65536, Err = error(resource_error(memory),length_rundown/2)
;  I = 5, N = 4294967296, Err = error(resource_error(memory),length_rundown/2)
;  I = 6, N = 18446744073709551616, Err = error(resource_error(memory),length_rundown/2)
;  I = 7, N = 340282366920938463463374607431768211456, Err = error(resource_error(memory),length_rundown/2)
;  I = 8, N = 115792089237316195423570985008687907853269984665640564039457584007913129639936, Err = error(resource_error(memory),length_rundown/2)
;  I = 9, N = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096, Err = null
;  I = 10, N = 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216, Err = null
; *** Error in `/opt/gupu/new-trealla/tpl': corrupted size vs. prev_size: 0x0000000001aedda0 ***
 I = 11, N = Aborted (core dumped)

@UWN
Copy link
Author

UWN commented Jul 9, 2023

All with

$ ulimit -v
50000

@UWN
Copy link
Author

UWN commented Jul 9, 2023

The interaction problem is gone, but

?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 4, N = 65536, Err = error(resource_error(memory),length_rundown/2)
;  I = 5, N = 4294967296, Err = error(resource_error(memory),length_rundown/2)
;  I = 6, N = 18446744073709551616, Err = error(resource_error(memory),length_rundown/2)
;  I = 7, N = 340282366920938463463374607431768211456, Err = error(resource_error(memory),length_rundown/2)
;  I = 8, N = 115792089237316195423570985008687907853269984665640564039457584007913129639936, Err = error(resource_error(memory),length_rundown/2)
; Segmentation fault (core dumped)

@UWN
Copy link
Author

UWN commented Jul 10, 2023

Now:

ulrich@p0:~$ ulimit -v 50000
ulrich@p0:~$ /opt/gupu/new-trealla/tpl
Trealla with .tplrc
Trealla Prolog (c) Infradig 2020-2023, v2.21.31
?- ulrich@p0:~$ /opt/gupu/new-trealla/tpl -f
Trealla Prolog (c) Infradig 2020-2023, v2.21.31
?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 9, N = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096, Err = null
; *** Error in `/opt/gupu/new-trealla/tpl': corrupted size vs. prev_size: 0x0000000001724e80 ***
 I = 10, N = Aborted (core dumped)

@infradig
Copy link
Contributor

infradig commented Jul 10, 2023 via email

@UWN
Copy link
Author

UWN commented Jul 10, 2023

On my newer lab-top. After git reset --hard && make clean

ulrich@TU-Wien:/opt/gupu/new-trealla$ ulimit -v
50000
ulrich@TU-Wien:/opt/gupu/new-trealla$ ./tpl
Trealla with .tplrc
Trealla Prolog (c) Infradig 2020-2023, v2.21.32
?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
; free(): double free detected in tcache 2
Aborted (core dumped)
ulrich@TU-Wien:/opt/gupu/new-trealla$ uname .a
uname: extra operand ‘.a’
Try 'uname --help' for more information.
ulrich@TU-Wien:/opt/gupu/new-trealla$ uname -a
Linux TU-Wien 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

@UWN
Copy link
Author

UWN commented Jul 10, 2023

After complete rebuild on p0:

ulrich@p0:~$ /opt/gupu/new-trealla/tpl -f
Trealla Prolog (c) Infradig 2020-2023, v2.21.32
?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 9, N = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096, Err = null
; *** Error in `/opt/gupu/new-trealla/tpl': corrupted size vs. prev_size: 0x0000000001f72e80 ***
 I = 10, N = Aborted (core dumped)
ulrich@p0:~$ /opt/gupu/new-trealla/tpl -f
Trealla Prolog (c) Infradig 2020-2023, v2.21.32
?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 9, N = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096, Err = null
; *** Error in `/opt/gupu/new-trealla/tpl': corrupted size vs. prev_size: 0x00000000023f7e80 ***
 I = 10, N = Aborted (core dumped)
ulrich@p0:~$ 

That there are different addresses in both runs is not surprising, because by default, memory is always allocated at a random place to prevent buffer overflow attacks and the like.

@UWN
Copy link
Author

UWN commented Aug 2, 2023

Now:

Trealla Prolog (c) Infradig 2020-2023, v2.23.41
?- length(_,I),N is 2^2^I, catch(length(L,N),Err,true).
   I = 0, N = 2, L = [_A,_B]
;  I = 1, N = 4, L = [_A,_B,_C,_D]
;  I = 2, N = 16, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 3, N = 256, L = [_A,_B,_C,_D,_E,_F,_G,_H,_I|...]
;  I = 9, N = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096, Err = null
; *** Error in `/opt/gupu/new-trealla/tpl': corrupted size vs. prev_size: 0x0000000002c2fb70 ***
 I = 10, N = Aborted (core dumped)

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

2 participants