Skip to content

jsauthority: ensure to call JS_Init() and JS_ShutDown() exactly once

Xi Ruoyao requested to merge xry111/polkit:xry111/jsinit into master

Before this commit, we were calling JS_Init() in polkit_backend_js_authority_class_init and never called JS_ShutDown. This is actually a misusage of SpiderMonkey API. Quote from a comment in js/Initialization.h (both mozjs-78 and mozjs-91):

It is currently not possible to initialize SpiderMonkey multiple
times (that is, calling JS_Init/JSAPI methods/JS_ShutDown in that
order, then doing so again).

This misusage does not cause severe issues with mozjs-78. However, when we eventually port jsauthority to use mozjs-91, bad thing will happen: see the test failure mentioned in #150 (closed).

This commit is tested with both mozjs-78 and mozjs-91, all tests pass with it.

Merge request reports