diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-23 20:53:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-23 20:53:11 -0700 |
commit | 2e0159fe467ac3ea9b89394ff2e8be77263a01d2 (patch) | |
tree | d4fe384b9f988823bc425b9f5072381aa9d681f1 /share | |
parent | 6c901d9d33b5fed938114224434cad2f2c069592 (diff) | |
download | txr-2e0159fe467ac3ea9b89394ff2e8be77263a01d2.tar.gz txr-2e0159fe467ac3ea9b89394ff2e8be77263a01d2.tar.bz2 txr-2e0159fe467ac3ea9b89394ff2e8be77263a01d2.zip |
New: stack overflow protection.
* configure: detect getrlimit, producing HAVE_RLIMIT in
config.h.
* eval.c (do_eval, do_expand): Call gc_stack_check inline
function to check stack pointer against limit.
* gc.c (gc_stack_bottom): Static becomes extern, so inline
function in gc.h can refer to it.
(gc_stack_limit): New global variable.
(gc_init): If we have rlimit, then probe RLIMIT_STACK.
If the stack is sufficiently large, then enable the stack
overflow protection, which kicks in when the stack pointer
appears to be within a certain percentage of the limit.
(set_stack_limit, get_stack_limit): New static functions.
(gc_late_init): Register set-stack-limit and get-stack-limit
intrinsics.
(gc_stack_overflow): New function.
* gc.h (gc_stack_bottom, gc_stack_limit, gc_stack_overflow):
Declared.
(gc_stack_check): New inline function.
* lib.c (stack_overflow_s): New symbol variable.
(obj_print_impl): Call gc_stack_check to protect recursive
printing againts overflow.
* lib.h (stack_overflow_s): Declared.
* unwind.c (uw_init): Register stack-overflow symbol as a an
exception symbol subtyped from error.
(uw_unwind_to_exit_point): When dealing with an unhandled
exception, turn off the stack limit, so we can print the
messages without triggering it in a loop.
* vm.c (vm_execute_closure, vm_funcall_common): Insert
gc_stack_check to the top of the execution of every VM
function.
* txr.1: Documented.
* share/txr/stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/doc-syms.tl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/share/txr/stdlib/doc-syms.tl b/share/txr/stdlib/doc-syms.tl index 006cf9d1..31e71438 100644 --- a/share/txr/stdlib/doc-syms.tl +++ b/share/txr/stdlib/doc-syms.tl @@ -859,6 +859,7 @@ ("get-obj" "N-0315B229") ("get-prop" "N-00663AE2") ("get-sig-handler" "N-02E1B6FA") + ("get-stack-limit" "N-02492D13") ("get-string" "N-00BE9AAC") ("get-string-from-stream" "N-037412EE") ("getaddrinfo" "N-0363FE99") @@ -1624,6 +1625,7 @@ ("set-prop" "N-03663AE4") ("set-right" "N-033F7D05") ("set-sig-handler" "N-02E1B6FA") + ("set-stack-limit" "N-02492D13") ("setegid" "N-03897D65") ("setenv" "N-002E0364") ("seteuid" "N-03897D65") |