[njs] Improved handling of traps inside trap handlers.

Dmitry Volyntsev xeioex at nginx.com
Thu Aug 30 17:37:22 UTC 2018


details:   http://hg.nginx.org/njs/rev/7ccb11c88d27
branches:  
changeset: 596:7ccb11c88d27
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Thu Aug 30 20:21:43 2018 +0300
description:
Improved handling of traps inside trap handlers.

diffstat:

 njs/njs_vm.c |  6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (16 lines):

diff -r 5dd7d38bb08c -r 7ccb11c88d27 njs/njs_vm.c
--- a/njs/njs_vm.c	Thu Aug 30 20:21:18 2018 +0300
+++ b/njs/njs_vm.c	Thu Aug 30 20:21:43 2018 +0300
@@ -3280,6 +3280,12 @@ njs_vmcode_restart(njs_vm_t *vm, njs_val
 
     ret = vmcode->code.operation(vm, value1, &frame->trap_values[1]);
 
+    if (nxt_slow_path(ret == NJS_TRAP)) {
+        /* Trap handlers are not reentrant. */
+        njs_internal_error(vm, "trap inside restart instruction");
+        return NXT_ERROR;
+    }
+
     retval = njs_vmcode_operand(vm, vmcode->operand1);
 
     //njs_release(vm, retval);


More information about the nginx-devel mailing list