GNOME Bugzilla – Bug 636927
dbus: Fix dict entry conversion path
Last modified: 2010-12-10 16:08:18 UTC
Multiple issues: * We need to handle JS_ValueToString possibly returning NULL, a look at the SpiderMonkey sources shows it can happen in unusual circumstances. * The JS_Add/RemoveRoot pairing was utterly fucked. Fix it by rooting everything at the top. * Move it to a separate function for sanity.
Created attachment 176157 [details] [review] dbus: Fix dict entry conversion path
Review of attachment 176157 [details] [review]: So much cleaner! ::: modules/dbus-values.c @@ +80,3 @@ + key_str = JS_ValueToString(context, key_value); + if (key_str == NULL) { + gjs_throw(context, "Couldn't convert value to string"); From looking through the code like JS_ValueToString will always set an exception if it fails.. "can't convert <whatever> to string" or something like that. (And certainly code calling it within spidermonkey assumes that.) So calling gjs_throw() here is going to overwrite that exception. Hmm, but that's OK, looking at gjs_throw() /* Often it's unclear whether a given jsapi.h function * will throw an exception, so we will throw ourselves * "just in case"; in those cases, we don't want to * overwrite an exception that already exists. * (Do log in case our second exception adds more info, * but don't log as topic ERROR because if the exception is * caught we don't want an ERROR in the logs.) */ so I think this is fine unless you think that this message is more important than whatever spidermonkey produced.
I've been running with this patch for more than half an hour, and gnome-shell didn't crash (the crash for which I provided backtraces on IRC which made you write this patch). The crash was pretty random anyway, so it's probably not conclusive, but it used to crash more often than that.
Confirming that this fixes the problem here on f14-64bit. gnome-shell was just crashing before the patch on startup.
Thanks for the confirmation of the fix!