[njs] Modules: fixed qjs engine after bellard/quickjs at 458c34d2.
noreply at nginx.com
noreply at nginx.com
Wed Jul 2 20:02:02 UTC 2025
details: https://github.com/nginx/njs/commit/c367f7e2fd2bf0147e950131f4b7887d178110f6
branches: master
commit: c367f7e2fd2bf0147e950131f4b7887d178110f6
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Tue, 1 Jul 2025 23:01:57 -0700
description:
Modules: fixed qjs engine after bellard/quickjs at 458c34d2.
Object leaks:
ADDRESS REFS SHRF PROTO CONTENT
0x512000007fc0 1 [module]
nginx: quickjs.c:1967: JS_FreeRuntime: Assertion `list_empty(&rt->gc_obj_list)' failed.
After bellard/quickjs at 458c34d2 modules are treated as GC objects and
tracked in rt->gc_obj_list. Intermediary module object loaded in
ngx_qjs_clone() using JS_ReadObject() needed to be freed for proper
ref_count accounting.
---
nginx/ngx_js.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c
index 448073b9..01d4bb2a 100644
--- a/nginx/ngx_js.c
+++ b/nginx/ngx_js.c
@@ -978,6 +978,11 @@ ngx_qjs_clone(ngx_js_ctx_t *ctx, ngx_js_loc_conf_t *cf, void *external)
"js load module exception: %V", &exception);
goto destroy;
}
+
+ if (i != length - 1) {
+ /* JS_EvalFunction() does JS_FreeValue(cx, rv) for the last rv. */
+ JS_FreeValue(cx, rv);
+ }
}
if (JS_ResolveModule(cx, rv) < 0) {
More information about the nginx-devel
mailing list