Closed
Bug 789382
Opened 12 years ago
Closed 12 years ago
nsIScriptError methods init() & initWithWindowID() should take nsAString, rather than wchar / PRUnichar*
Categories
(Core :: XPConnect, defect)
Core
XPConnect
Tracking
()
RESOLVED
FIXED
mozilla18
People
(Reporter: dholbert, Assigned: dholbert)
References
Details
Attachments
(2 files, 2 obsolete files)
4.13 KB,
patch
|
bzbarsky
:
review+
benjamin
:
superreview+
|
Details | Diff | Splinter Review |
29.61 KB,
patch
|
dholbert
:
review+
|
Details | Diff | Splinter Review |
As bz noted in bug 786108 comment 9, it's a little counterproductive that nsIScriptError's init() and initWithWindowID() methods take PRUnichar* -- they could just as easily take nsAString, which would be more abstract & could allow for string-sharing in some cases. Filing this bug on making that change.
Assignee | ||
Comment 1•12 years ago
|
||
I'm splitting this into two patches, for (hopefully) clearer/easier reviewing: Patch 1) The changes to the IDL & the impl. Patch 2) The changes to all the client code. I believe Patch 1 needs sr (as an API change), but patch 2 doesn't. (I intend to fold the two patches together before I land, since Patch 1 by itself won't successfully build.)
Attachment #659117 -
Flags: superreview?
Attachment #659117 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•12 years ago
|
Attachment #659117 -
Flags: superreview? → superreview?(benjamin)
Assignee | ||
Updated•12 years ago
|
Attachment #659117 -
Attachment filename: 788862-changeAPI.patch → 789382-changeAPI.patch
Assignee | ||
Comment 2•12 years ago
|
||
This patch was pretty mechanical -- basically just: s/foo.get()/foo/ s/rawString/nsDependentString(rawString)/ s/nullptr/EmptyString()/ There are also a few static_casts sprinkled in, for strictness -- replacing reinterpret_casts and C-style casts, since we don't need the power of reinterpret_cast / c-style casts in those spots. (I also simplified for consistency in a few places -- e.g. just calling NS_ConvertUTF8toUTF16() directly in mozJSComponentLoader.cpp's call to init(), since that's shorter & it's the pattern we follow almost everywhere. Also one old nullcheck-after-new.) CAVEAT: I haven't tested this yet; I've just confirmed that it successfully builds. :)
Attachment #659123 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 3•12 years ago
|
||
Note: The s/nullptr/EmptyString()/ changes are fine (won't change behavior) because nsScriptError::InitWithWindowID() just calls e.g. mSourceLine.Assign(sourceLine), and Assign() ends up truncating & returning when it's passed a null pointer: https://mxr.mozilla.org/mozilla-central/source/xpcom/string/src/nsTSubstring.cpp?mark=297-301#295
Assignee | ||
Comment 4•12 years ago
|
||
Forgot to rev the uuid -- fixed in this new version.
Attachment #659117 -
Attachment is obsolete: true
Attachment #659117 -
Flags: superreview?(benjamin)
Attachment #659117 -
Flags: review?(bzbarsky)
Attachment #659124 -
Flags: superreview?(benjamin)
Attachment #659124 -
Flags: review?(bzbarsky)
Comment 5•12 years ago
|
||
Comment on attachment 659124 [details] [diff] [review] Patch 1 v2: Change API & Impl r=me
Attachment #659124 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 6•12 years ago
|
||
(I imagine this will break some comm-central code -- this will probably need a corresponding comm-central bug & patch.)
Comment 7•12 years ago
|
||
Comment on attachment 659123 [details] [diff] [review] Patch 2: Changes to client code Please test on try. Going from const jschar* to const PRUnichar* used to require a reinterpret_cast on some platforms, iirc. In the XBL_ProtoErrorReporter I'm a little worried about ucmessage or uclinebuf being null. Can they be? Some other places certainly null-check at least ucmessage. Similar in the IndexedDatabaseManager. And the component loader. And XPCComponents. And XPCConvert (just uclinebuf). r=me with those fixed or the worry allayed.
Attachment #659123 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 8•12 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #7) > Comment on attachment 659123 [details] [diff] [review] > Patch 2: Changes to client code > > Please test on try. Going from const jschar* to const PRUnichar* used to > require a reinterpret_cast on some platforms, iirc. I don't think that's an issue anymore -- in at least some of the patch's chunks, we were already using static_cast for that conversion, so that shouldn't cause problems. (that's what tipped me off that we could use reinterpret_cast, and I changed it for consistency) (I'll look into the other null-checks & address them as-needed -- thanks for bringing that up! I'd assumed that nsDependentString(nsnull) would do the right thing & produce an empty string, but it looks like that'll assert, so we do need to be sure we're not passing in null there.) FWIW: The (non-Android) Try builders didn't quite finish the full build process, due to issues in "make package" & friends, due to .jsm files needing updates to their nsIScriptError usage I believe. For reference, the try push was: https://tbpl.mozilla.org/?tree=Try&rev=03bc6d4c751c and from a quick grep, it looks like e.g. https://mxr.mozilla.org/mozilla-central/source/browser/devtools/tilt/TiltUtils.jsm#72 will need an update, and others as well. So, I'll include a third patch for _JS_ client code.
Comment 9•12 years ago
|
||
That's really odd. JS should have been completely unaffected, since JS strings will Just Work and XPConnect will convert JS null to an empty AString.... I wonder whether the JS callers had "undefined" there or something?
Assignee | ||
Comment 10•12 years ago
|
||
I actually think the jsm files are fine after all -- it was likely that we were running a packaging tool *to package those files*, and that packaging tool involves one of the tweaked C++ classes, it crashed on a null pointer due to the null-checks mentioned in comment 7.
Assignee | ||
Comment 11•12 years ago
|
||
(or rather, due to the _lack_ of those null-checks)
Assignee | ||
Comment 12•12 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #7) > Comment on attachment 659123 [details] [diff] [review] > In the XBL_ProtoErrorReporter I'm a little worried about ucmessage or > uclinebuf being null. Can they be? I think they can be. They're initialized to null (from the struct getting a memset(0)), in at least some cases, and we do have null-checks elsewhere, so might as well null-check them here. So: added null-checks there. > Similar in the IndexedDatabaseManager. We're OK there, because both of the strings come from an nsString. I've now just replaced the nsDependentString(buf) invocation with the actual nsString ("errorName") there, and I added an assertion that the other one is non-null (which we're guaranteed from how it's set, in FillScriptErrorEvent, here: > aEvent->fileName = mFilename.get(); https://mxr.mozilla.org/mozilla-central/source/dom/indexedDB/IDBRequest.cpp?mark=227-227#223 And mFilename is a (concrete) nsString, declared here: https://mxr.mozilla.org/mozilla-central/source/dom/indexedDB/IDBRequest.h#103 so its .get() method should return non-null. > And the component loader. Added null-checks. > And XPCComponents. Added null-checks. > And XPCConvert (just uclinebuf). Added null-check for uclinebuf. > r=me with those fixed or the worry allayed. Thanks! Carrying forward r+, -- all of the above is fixed except for the IndexedDatabaseManager chunk, and hopefully I allayed your worries there?
Attachment #659123 -
Attachment is obsolete: true
Attachment #659334 -
Flags: review+
Comment 13•12 years ago
|
||
Sounds good!
Assignee | ||
Updated•12 years ago
|
Attachment #659334 -
Attachment description: patch 2 v2: Changes to client code → patch 2 v2: Changes to client code [r=bz]
Updated•12 years ago
|
Attachment #659124 -
Flags: superreview?(benjamin) → superreview+
Assignee | ||
Comment 14•12 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/70a0eda09c3c
Status: NEW → ASSIGNED
Comment 15•12 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/70a0eda09c3c
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
Comment 16•12 years ago
|
||
>(I imagine this will break some comm-central code -- this will probably need a
> corresponding comm-central bug & patch.)
Oh it did, and it does. Please file necessary comm-central bugs instead of waiting for us to discover stuff like this by having our trees catch fire.
Assignee | ||
Comment 17•12 years ago
|
||
Oops! Very sorry about that -- I forgot about that impact of this bug at some point after posting that comment. I've filed bug 790157 to fix comm-central, and I can look into fixing it tomorrow morning. Should I back out in the meantime? (if so, I can do that in the morning) (I don't see burning over on https://tbpl.mozilla.org/?tree=Thunderbird-Trunk , but maybe that's because this hasn't been merged there yet? I don't really know how comm-central TBPL / build mechanics work.)
Comment 18•12 years ago
|
||
> (I don't see burning over on https://tbpl.mozilla.org/?tree=Thunderbird-Trunk) It appear to affect only Lightning. However Lightning is pretty integral to Thunderbird. See Bug 790015.
Assignee | ||
Updated•12 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•