Closed
Bug 90597
Opened 24 years ago
Closed 24 years ago
CACHED_SET/CACHED_GET refcount bug
Categories
(Core :: JavaScript Engine, defect, P1)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
mozilla0.9.3
People
(Reporter: epstein, Assigned: brendan)
References
Details
(Keywords: js1.5)
Attachments
(3 files)
|
1.88 KB,
patch
|
Details | Diff | Splinter Review | |
|
3.54 KB,
patch
|
Details | Diff | Splinter Review | |
|
2.75 KB,
patch
|
Details | Diff | Splinter Review |
The CACHED_SET and CACHED_GET macros have code like this:
sprop->nrefs++;
ok = SPROP_{G,S}ET(...);
if (ok)
{
...
js_DropScopeProperty(..., sprop);
}
if SPROP_{G,S}ET fails, js_DropScopeProperty is never called. This causes that
JSScopeProperty to have a one-too-high refcount, which results in two problems:
(a) The JSScopeProperty will never be freed, because it is only freed when its
refcount drops to 0. Hence memory leak.
(b) If the JSScopeProperty is in the property cache, after its refcount drops
to 1 its "symbols" list is null, causing PROPERTY_CACHE_TEST to call something
like sym_id, which derefs symbols and crashes.
I will attach a proposed patch shortly.
| Reporter | ||
Comment 1•24 years ago
|
||
| Assignee | ||
Updated•24 years ago
|
Severity: normal → critical
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → mozilla0.9.3
| Assignee | ||
Comment 4•24 years ago
|
||
That patch is fine, apart from the discordant brace style. Thanks, please feel
free to use it, or the style-conforming version of it I'm about to attach.
Cc'ing reviewers, please do your things.
/be
| Assignee | ||
Comment 5•24 years ago
|
||
Actually, my patch fixes a problem in the first patch: you must JS_LOCK_SCOPE
before calling js_DropScopeProperty.
/be
| Assignee | ||
Comment 6•24 years ago
|
||
| Assignee | ||
Comment 7•24 years ago
|
||
| Assignee | ||
Comment 8•24 years ago
|
||
rogerl, how about r=? jband, sr=? shaver, for good measure.
/be
Comment 9•24 years ago
|
||
I certainly don't know enough about this area. Is it really ok to continue after
receiving a FALSE from SPROP_GET? I know we'll return the FALSE value soon
enough but some significant (looking) code is executed first. Throughout the
rest of the engine we interpret a FALSE value as a signal to bail out - as if an
exception were thrown. Is it the case that, no matter what caused the initial
failure, it's ok to continue with the rest of the sequence?
| Assignee | ||
Comment 10•24 years ago
|
||
rogerl: ok is tested after each CACHED_GET or CACHED_SET call, and if false, we
goto out (possibly cleaning up anything that would leak otherwise). The patch
must drop the found sprop and unlock the scope, however -- that's the bug being
fixed here.
/be
Comment 11•24 years ago
|
||
Just ran the JS test suite on Linux with patch (id=42516) applied.
No new regressions introduced. All test failures are previously known,
and due to other bugs still being worked on -
| Assignee | ||
Comment 12•24 years ago
|
||
hyatt says r/sr=hyatt, waterson says sr/r=waterson -- I'm so happy!
/be
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 14•24 years ago
|
||
*** Bug 84720 has been marked as a duplicate of this bug. ***
You need to log in
before you can comment on or make changes to this bug.
Description
•