Open Bug 1498277 Opened 1 year ago Updated 1 year ago
Preloader::Cached Script::Get JSScript(JSContext* cx) always returns null
The if-condition in this code is upside-down: https://searchfox.org/mozilla-central/rev/1ce4e8a5601da8e744ca6eda69e782318afab54d/js/xpconnect/loader/ScriptPreloader.cpp#1229 If JS::DecodeScript succeeds, it returns JS::TranscodeResult_Ok, which is zero. It's treated as false; the body of the if-block in GetJSScript is skipped; `script` is never stored in `mScript`; ScriptPreloader::CachedScript::GetJSScript returns null. If JS::DecodeScript fails, it returns a non-zero value, but `script` is still null, so ScriptPreloader::CachedScript::GetJSScript still returns null. In any case the error code is lost. : https://searchfox.org/mozilla-central/rev/1ce4e8a5601da8e744ca6eda69e782318afab54d/js/src/jsapi.cpp#7037 : https://searchfox.org/mozilla-central/rev/1ce4e8a5601da8e744ca6eda69e782318afab54d/js/public/Transcoding.h#48
(In reply to Jason Orendorff [:jorendorff] from comment #1) > We need the capability to turn a TranscodeResult into a JS exception anyway > for bug 1458209. We do have that in the JS shell , but I found that matching enumerated error code had the benefit of not making any allocation and also to be easy to compare.  https://searchfox.org/mozilla-central/rev/1ce4e8a5601da8e744ca6eda69e782318afab54d/js/src/shell/js.cpp#1849-1891
It doesn't always return null. The sync decode is only a fallback for when an off-thread decode result isn't already ready. But that case should still be fixed.
You need to log in before you can comment on or make changes to this bug.