After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 691038 - Fixes for debug builds of mozjs187
Fixes for debug builds of mozjs187
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2013-01-02 23:00 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2013-01-04 22:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
function: Add BeginRequest/EndRequest for JS_ValueRoot (1.03 KB, patch)
2013-01-02 23:00 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
gi: Use raw JS_GetPrivate from tracing callbacks (1.31 KB, patch)
2013-01-02 23:00 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
util: Add BeginRequest/EndRequest back to priv_from_js (1.88 KB, patch)
2013-01-02 23:00 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
Make sure that all calls to BOOLEAN_TO_JSVAL pass a true boolean (1.46 KB, patch)
2013-01-04 18:31 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2013-01-02 23:00:39 UTC
When trying to use JS_DumpHeap, I found that these additional
assertions were added, crashing the shell. We should probably
all use debug builds.
Comment 1 Jasper St. Pierre (not reading bugmail) 2013-01-02 23:00:41 UTC
Created attachment 232588 [details] [review]
function: Add BeginRequest/EndRequest for JS_ValueRoot
Comment 2 Jasper St. Pierre (not reading bugmail) 2013-01-02 23:00:43 UTC
Created attachment 232589 [details] [review]
gi: Use raw JS_GetPrivate from tracing callbacks

We don't need a type-check, as we already know it's the right
class. priv_from_js is going to gain BeginRequest/EndRequest,
which we can't use from tracing hooks, so omit those for now.
Comment 3 Jasper St. Pierre (not reading bugmail) 2013-01-02 23:00:45 UTC
Created attachment 232590 [details] [review]
util: Add BeginRequest/EndRequest back to priv_from_js

Even though JS_GetInstancePrivate isn't documented as needing a
request, it does.
Comment 4 Giovanni Campagna 2013-01-03 00:29:19 UTC
Review of attachment 232590 [details] [review]:

Calling begin/end only inside the priv_from_js looks wrong to me: once the context is unlocked, the object might be GCed and the returned value might be garbage. Unless I misunderstand the point of Begin/EndRequest, that is.
Comment 5 Giovanni Campagna 2013-01-03 00:29:51 UTC
Review of attachment 232589 [details] [review]:

Yes.
Comment 6 Jasper St. Pierre (not reading bugmail) 2013-01-03 00:44:10 UTC
(In reply to comment #4)
> Review of attachment 232590 [details] [review]:
> 
> Calling begin/end only inside the priv_from_js looks wrong to me: once the
> context is unlocked, the object might be GCed and the returned value might be
> garbage. Unless I misunderstand the point of Begin/EndRequest, that is.

Stack scanning prevents that from happening.
Comment 7 Giovanni Campagna 2013-01-03 00:47:01 UTC
(In reply to comment #6)
> (In reply to comment #4)
> > Review of attachment 232590 [details] [review] [details]:
> > 
> > Calling begin/end only inside the priv_from_js looks wrong to me: once the
> > context is unlocked, the object might be GCed and the returned value might be
> > garbage. Unless I misunderstand the point of Begin/EndRequest, that is.
> 
> Stack scanning prevents that from happening.

*If* the returned values lives on the stack, but we really hope it is not, considering how hot is priv_from_js.
Anyway, priv_from_js is only called for alive (reachable) objects, and the GC thread cannot make them unreachable, so perhaps this is a false concern.
Comment 8 Jasper St. Pierre (not reading bugmail) 2013-01-03 22:23:11 UTC
So does that mean it's ACN?
Comment 9 Giovanni Campagna 2013-01-03 22:47:42 UTC
(In reply to comment #8)
> So does that mean it's ACN?

It means I'm not sure, so I'd prefer if someone else looked at this too.
It's very easy to get GC wrong without immediate consequences, and I'd like to avoid hard to reproduce crashes.
Comment 10 Jasper St. Pierre (not reading bugmail) 2013-01-04 18:31:30 UTC
Created attachment 232778 [details] [review]
Make sure that all calls to BOOLEAN_TO_JSVAL pass a true boolean

Debug builds of libmozjs assert that the value passed to BOOLEAN_TO_JSVAL
is not just truthy, but one of JS_FALSE (0) or JS_TRUE (1). We can't
possibly fix all API consumers to respect this rule, so do the conversion
for them.
Comment 11 Jasper St. Pierre (not reading bugmail) 2013-01-04 18:59:53 UTC
(In reply to comment #7)
> *If* the returned values lives on the stack, but we really hope it is not,
> considering how hot is priv_from_js.

There's a bit of code to dump registers onto the stack in that case.
Comment 12 Giovanni Campagna 2013-01-04 19:14:34 UTC
(In reply to comment #11)
> (In reply to comment #7)
> > *If* the returned values lives on the stack, but we really hope it is not,
> > considering how hot is priv_from_js.
> 
> There's a bit of code to dump registers onto the stack in that case.

Ah, nice. Acn then.
Comment 13 Giovanni Campagna 2013-01-04 19:15:44 UTC
Review of attachment 232778 [details] [review]:

Yes

(And it is really bad on the libmozjs side to assert such a thing, when they can just !! themselves)
Comment 14 Jasper St. Pierre (not reading bugmail) 2013-01-04 22:08:21 UTC
Attachment 232588 [details] pushed as bac272f - function: Add BeginRequest/EndRequest for JS_ValueRoot
Attachment 232589 [details] pushed as fba2a34 - gi: Use raw JS_GetPrivate from tracing callbacks
Attachment 232590 [details] pushed as 3937d5f - util: Add BeginRequest/EndRequest back to priv_from_js
Attachment 232778 [details] pushed as 46b1443 - Make sure that all calls to BOOLEAN_TO_JSVAL pass a true boolean