This problem is similar to previous commits. When
njs_error_stack_attach() accepted the value as a pointer to vm->retval
that value might be changed as a side effert of njs_error_stack_new()
evaluation. This may result in a garbage value for
njs_object(value) expression.
The workaround fix is to make a copy of vm->retval to ensure its
intergrity and to preserve it as a retval. The proper fix is to
eliminate vm->retval altogether.
This fixes #612, #613, #616 issues on Github.
if (njs_is_error(&vm->retval)) {
vm->active_frame->native.pc = pc;
- (void) njs_error_stack_attach(vm, &vm->retval);
+
+ /* TODO: get rid of copying. */
+
+ njs_value_assign(&dst, &vm->retval);
+ (void) njs_error_stack_attach(vm, &dst);
+ njs_value_assign(&vm->retval, &dst);
}
for ( ;; ) {
{ njs_str("function f(n) { if (n == 0) { throw 'a'; } return f(n-1); }; f(2)"),
njs_str("a") },
+ { njs_str("Object.defineProperty(Function.__proto__, 'name', {get() { typeof 1;}});"
+ "(new Uint8Array()).every()"),
+ njs_str("TypeError: callback argument is not callable\n"
+ " at TypedArray.prototype.every (native)\n"
+ " at main (:1)\n") },
+
/* line numbers */
{ njs_str("/**/(function(){throw Error();})()"),