]> git.kaiwu.me - njs.git/commit
Fixed call argument value snapshotting.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 15 May 2026 23:28:47 +0000 (16:28 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 18 May 2026 16:24:27 +0000 (09:24 -0700)
commit7d1706c20a71d3e864d61b74f9aa2448d265cce6
tree7f988ebfecdca320c8ac4bbc8030cd681dc1fccf
parent5cd5ebf592e4ff39336a218ac5206f913adebde1
Fixed call argument value snapshotting.

Since fd5e523f (0.9.7), njs has evaluated all call argument expressions
before emitting the frame and PUT_ARG instructions.  This fixed await
expressions in call arguments and preserved argument side effects before
callee validation, but left PUT_ARG reading argument values only after later
argument expressions had already run.

As a result, an earlier argument backed by a mutable variable slot could
observe a later mutation of the same slot.  For example, f(a, a = 2) passed
2 as both arguments instead of preserving the first value as 1.  The same
issue applied to later argument effects such as getters.

The fix is to preserve affected argument values in temporary registers where
appropriate.

This fixes #1059 issue on Github.
src/njs_generator.c
src/test/njs_unit_test.c