You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Behavior changes: read before upgrading
1. An mruby_set or mruby_set_code argument that interpolates a variable no longer ends the worker or leaves the request without a response (#921)
Before: built on nginx 1.31.3, 1.30.4 or 1.30.5, an mruby_set or mruby_set_code directive with extra arguments, one or more of which interpolate a variable (two or more for mruby_set, for example mruby_set $v script.rb "$host" "x";), either ended the worker process (signal 11) or left the request without a response (the connection closed with no reply, curl: (52) Empty reply from server, after about 75 seconds) when the variable was evaluated; which of the two happened depended on the memory layout. The vendored ngx_devel_kit emitted the nginx complex value code without the end code that those nginx versions expect, so the script stack was left short. Built on any other nginx version, including the 1.31.8 and 1.30.6 that ngx_mruby pins, the directive worked, but the evaluated argument kept the length that the length pass had predicted, which can exceed the bytes written; ngx_mruby's set handler does not read that length, so the response was unchanged.
Now: on the nginx versions that have the end code (1.30.4 and later 1.30.x, 1.31.3 and later; not freenginx), the vendored ngx_devel_kit appends it, so the argument is evaluated, with a response and without ending the worker, on nginx 1.31.3, 1.30.4 and 1.30.5, and the end code trims the evaluated argument to the bytes written. On nginx before 1.30.4, on 1.31.0 to 1.31.2 and on freenginx, which have no end code, the guard leaves it out and the directive works as before. The response on nginx 1.31.8 and 1.30.6 is unchanged. The documented forms mruby_set $v script.rb; and mruby_set $v script.rb cache;, whose arguments interpolate no variable, were never affected.
Why it changed:
The defect: mainline nginx 1.31.3 and stable 1.30.4 moved the script stack update of a complex value to a new end code (nginx commit a8289aa69c74). The vendored ngx_devel_kit, which reuses the complex value code in ndk_http_rewrite_value, did not emit it, so the stack was left short and, when the value was evaluated, the worker ended or the request got no response. Mainline nginx 1.31.4 and stable 1.30.6 restored the stack update in the complex value code and turned a missing end code into a result string that keeps the predicted length (nginx commit 4b90ec769235, PR #1601). The nginx 1.30.6 changelog records this fix for third-party modules that use the script codes and notes that the problem appeared in 1.30.4, so the stable releases 1.30.4 and 1.30.5 are affected and 1.30.6 is not.
Why the old behavior could not be kept: on nginx 1.31.3, 1.30.4 and 1.30.5 the worker ended or the request got no response, so such a directive could not run there at all; emitting the end code, as nginx's own rewrite module does, is what lets the argument be evaluated and keeps the result string at the bytes written.
What the documentation promised: the mruby_set directives of 2.7.18 describe mruby_set $VARNAME /PATH/TO/SCRIPT.rb [cache]; and mruby_set_code $VARNAME 'CODE';, and say nothing about extra arguments that interpolate a variable. The nginx documentation does not describe the script codes (ngx_http_script_complex_value_code) that a module reuses.
Affected: mruby_set and mruby_set_code with extra arguments, one or more of which interpolate a variable (two or more for mruby_set), when the module is built on nginx 1.31.3, 1.30.4 or 1.30.5. The documented [cache] form, a directive with no interpolated argument, and builds on any other nginx version are unaffected.
What to do: rebuild the module with this release; no configuration change is needed. If you build on nginx 1.31.3, 1.30.4 or 1.30.5 and a configuration uses such a directive, this release is required.