Mercurial > njs
changeset 2580:ecf2499ed755
Modules: fixed qjs engine after bellard/quickjs@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@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.
| author | Dmitry Volyntsev <xeioex@nginx.com> |
|---|---|
| date | Tue, 01 Jul 2025 23:01:57 -0700 |
| parents | 8b6a2ce70d39 |
| children | 3c89db25314d |
| files | nginx/ngx_js.c |
| diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/nginx/ngx_js.c Mon Jun 16 19:36:35 2025 -0700 +++ b/nginx/ngx_js.c Tue Jul 01 23:01:57 2025 -0700 @@ -978,6 +978,11 @@ "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) {
