Closed
Bug 1447272
Opened 6 years ago
Closed 6 years ago
Port Bug 1442239 - Disable nsISerializable.Read from nsIURI implementations
Categories
(MailNews Core :: Backend, enhancement)
MailNews Core
Backend
Tracking
(Not tracked)
RESOLVED
FIXED
Thunderbird 61.0
People
(Reporter: jorgk-bmo, Assigned: jorgk-bmo)
References
Details
Attachments
(2 files, 6 obsolete files)
2.99 KB,
patch
|
aceman
:
review+
|
Details | Diff | Splinter Review |
3.99 KB,
patch
|
aceman
:
review+
|
Details | Diff | Splinter Review |
Looks like we need to remove the nsXXXUrl::Mutator::Read() methods, example here: https://hg.mozilla.org/mozilla-central/rev/61aa0247279a#l6.12
Assignee | ||
Comment 1•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Assignee: nobody → jorgk
Status: NEW → ASSIGNED
Target Milestone: --- → Thunderbird 61.0
Pushed by mozilla@jorgk.com: https://hg.mozilla.org/comm-central/rev/3ab4909ae468 Port Bug 1442239 to mailnews: Remove nsXXXUrl::Mutator::Read() methods. rs=bustage-fix
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 3•6 years ago
|
||
Looks like this was the wrong fix or at least an incomplete fix. TB crashes pretty much straight away and all tests are red (due to crashes). Looks like it crashes when reading parts for the URL, like in GetScheme() or IsScheme(). The M-C changes https://hg.mozilla.org/mozilla-central/rev/61aa0247279a don't give a clear example.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Comment 5•6 years ago
|
||
So, what this patch did was remove the ability to initialize a URL by calling ::Read() on it directly.
What you have to do instead, is create a mutator of the type you want, and call Read on that. The mutator will forward the call to ReadPrivate().
So what your fix should do:
For nsIURI implementations that also inherit nsISerializable you should move all the code from Read() to ReadPrivate(). Read should only contain:
> NS_NOTREACHED("Use nsIURIMutator.read() instead");
> return NS_ERROR_NOT_IMPLEMENTED;
Then the mutator for each of those classes should extend nsISerializable. The Write implementation should return NS_ERROR_NOT_IMPLEMENTED. The Read implementation should call InitFromInputStream(aStream)
Flags: needinfo?(valentin.gosu)
Assignee | ||
Comment 6•6 years ago
|
||
OK, the previous patch was completely wrong and will be backed out. This one compiles so far, let's see whether it runs.
Attachment #8960529 -
Attachment is obsolete: true
Assignee | ||
Comment 7•6 years ago
|
||
Attachment #8960663 -
Attachment is obsolete: true
Assignee | ||
Comment 8•6 years ago
|
||
This does what you decribed, however, TB just doesn't work and crashes. Before it crashes, it spits out a lot of errors, like: [7532, Main Thread] WARNING: '!aURI', file c:/mozilla-source/comm-central/mozill a/netwerk/base/nsIURIMutatorUtils.cpp, line 8 [7532, Main Thread] WARNING: NS_ENSURE_SUCCESS_VOID(mStatus) failed with result 0x80070057: file c:/mozilla-source/comm-central/mozilla/netwerk/base/nsIURIMutat orUtils.cpp, line 17 [7532, Main Thread] WARNING: NS_ENSURE_SUCCESS(mStatus, mStatus) failed with res ult 0x80070057: file c:\mozilla-source\comm-central\obj-x86_64-pc-mingw32\dist\i nclude\nsIURIMutator.h, line 607 [7532, Main Thread] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x8007 0057: file c:/mozilla-source/comm-central/mailnews/base/util/nsMsgMailNewsUrl.cp p, line 421 nsMsgMailNewsUrl.cpp, line 421 is nsresult rv = NS_MutateURI(m_baseURL).SetSpec(aSpec).Finalize(m_baseURL); NS_ENSURE_SUCCESS(rv, rv);
Attachment #8960665 -
Attachment is obsolete: true
Attachment #8960670 -
Flags: feedback?(valentin.gosu)
Comment 9•6 years ago
|
||
nsIURIMutatorUtils.cpp, line 8 The problem here is that m_BaseURL is probably null.
Comment 10•6 years ago
|
||
Comment on attachment 8960670 [details] [diff] [review] 1447272-adjust-read-write.patch (v1c) Review of attachment 8960670 [details] [diff] [review]: ----------------------------------------------------------------- ::: ldap/xpcom/src/nsLDAPURL.h @@ +70,5 @@ > } > > NS_IMETHOD Read(nsIObjectInputStream* aStream) override > { > + NS_NOTREACHED("Use nsIURIMutator.read() instead"); this should just be: return InitFromInputStream(aStream); @@ +76,5 @@ > } > > + nsresult ReadPrivate(nsIObjectInputStream* aStream) > + { > + return InitFromInputStream(aStream); ReadPrivate must be defined on the URI, not the mutator. InitFromInputStream is the one calling ReadPrivate. ::: mailnews/addrbook/src/nsAddbookUrl.h @@ +62,5 @@ > + } > + > + NS_IMETHOD Write(nsIObjectOutputStream *aOutputStream) override > + { > + return NS_ERROR_NOT_IMPLEMENTED; same for this mutator. ::: mailnews/compose/src/nsSmtpUrl.h @@ +100,5 @@ > eHonorRef, > eReplaceRef > }; > virtual ~nsMailtoUrl(); > + nsresult ReadPrivate(nsIObjectInputStream *aStream); So, you should actually define nsMailtoUrl::ReadPrivate() not just declare it.
Attachment #8960670 -
Flags: feedback?(valentin.gosu)
Assignee | ||
Comment 11•6 years ago
|
||
(In reply to Valentin Gosu [:valentin] from comment #10) > So, you should actually define nsMailtoUrl::ReadPrivate() not just declare > it. OK, and what should it do? Sorry about the (silly/ignorant) question.
Comment 12•6 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #11) > (In reply to Valentin Gosu [:valentin] from comment #10) > > So, you should actually define nsMailtoUrl::ReadPrivate() not just declare > > it. > OK, and what should it do? Sorry about the (silly/ignorant) question. URIImplementation::ReadPrivate should do exactly what Read does now. URIImplementation::Read should call NS_NOTREACHED so we don't call it by mistake, and return not_implemented. URIImplementation::Mutator::Read should call initFromStream URIImplementation::Mutator::Write should return not implemented.
Assignee | ||
Comment 13•6 years ago
|
||
(In reply to Valentin Gosu [:valentin] from comment #12) > URIImplementation::ReadPrivate should do exactly what Read does now. Yes, that's what I saw in your patches, for example here: https://hg.mozilla.org/mozilla-central/rev/61aa0247279a#l12.12 The only problem is, our URL's never had a Read() method. And the mutator Read() said "not implemented". So now the Mutator::Read calls initFromStream() which in turn calls ReadPrivate() on the URL which we don't have and never had.
Comment 14•6 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #13) > (In reply to Valentin Gosu [:valentin] from comment #12) > > URIImplementation::ReadPrivate should do exactly what Read does now. > Yes, that's what I saw in your patches, for example here: > https://hg.mozilla.org/mozilla-central/rev/61aa0247279a#l12.12 > > The only problem is, our URL's never had a Read() method. And the mutator > Read() said "not implemented". So now the Mutator::Read calls > initFromStream() which in turn calls ReadPrivate() on the URL which we don't > have and never had. Oh, if the URI doesn't implement nsISerializable (so it doesn't have Read/Write methods) - then the mutator for that class shouldn't implement nsISerializable.
Assignee | ||
Comment 15•6 years ago
|
||
Right, that's why the patch I landed https://hg.mozilla.org/comm-central/rev/3ab4909ae468 Port Bug 1442239 to mailnews: Remove nsXXXUrl::Mutator::Read() methods. rs=bustage-fix removed the Read() methods from the mutator. That compiled, but it crashes left, right and centre, and about all our tests fail, see comment #3. So where from here?
Comment 16•6 years ago
|
||
In that case we probably need to audit all the classes that implement nsIURI and nsISerializable, or that extend a class that does. I assume there are a few.
Assignee | ||
Comment 17•6 years ago
|
||
Hmm, I'm not sure I follow. We have four URL classes: address book, LDAP, MailTo. These extend nsIURI, that is, the objects have a pointer to a "base URL" of nsIURI. The 4th class, the "mailnews URL" extends nsIURL and has a pointer to nsIURL. None of these classes have a Read() method so far. And I had never heard of nsISerializable, it's not used in C-C.
Comment 18•6 years ago
|
||
You're right, looking on searchfox, it seems comm-central URLs don't extend nsISerializable. The initial patch removing the Read methods should have worked. The build and test failures don't make much sense to me. As I said in comment 9, the error there is that the URL being mutated is null.
Assignee | ||
Comment 19•6 years ago
|
||
Hmm, if you're referring to the build failures you can see on the C-C tree, they have a different cause. We all agree that the problem is that the URL being mutated is null. I've just tracked one case: nsImapService::CreateStartOfImapUrl() https://dxr.mozilla.org/comm-central/rev/a8eecfe6de793af00e98cb1488515199c5fb73fb/mailnews/imap/src/nsImapService.cpp#1345 That creates an "IMAP URL", QI's it to nsIMsgMailNewsUrl, then calls nsIMsgMailNewsUrl::SetSpecInternal() and that thing mutates the underlying URL (m_baseURL), which appears to be null. That code worked until today, so I'm not sure what's changed.
Assignee | ||
Comment 20•6 years ago
|
||
Comment on attachment 8960529 [details] [diff] [review] 1447272-remove-mutator-read.patch Maybe not so wrong after all ;-)
Attachment #8960529 -
Attachment is obsolete: false
Assignee | ||
Comment 21•6 years ago
|
||
This avoids the crash, but I still get heaps of errors from nsSmtpService.cpp line 318 and nsSmtpUrl.cpp line 269.
Attachment #8960670 -
Attachment is obsolete: true
Comment 22•6 years ago
|
||
So, SetSpecInternal doesn't really need to mutate anything. You can just create a new mutator and SetSpec on that.
Assignee | ||
Comment 23•6 years ago
|
||
See where this gets us: https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=ae3606097f3b95f8fa02d5ca3c8726fbe49f9dd0
Assignee | ||
Comment 24•6 years ago
|
||
(In reply to Valentin Gosu [:valentin] from comment #22) > So, SetSpecInternal doesn't really need to mutate anything. You can just > create a new mutator and SetSpec on that. I think it doesn't really matter whether it mutates the old one or creates a new one straight away. If you look at the constructor of nsMsgMailNewsUrl, it does m_baseURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID); And, BTW, all out URLs initialise that member in the constructor. So I'm at a complete loss to understand what has happened here. The bug we're porting is about removing some nsISerializable.Read. Now, our URLs don't inherit from that, so removing the Read() methods should just do the trick. But somehow the behaviour of the underlying URLs seems to have changed completely. What does https://dxr.mozilla.org/comm-central/rev/a8eecfe6de793af00e98cb1488515199c5fb73fb/mailnews/imap/src/nsImapService.cpp#1345 actually do? rv = CallCreateInstance(kImapUrlCID, imapUrl); no longer creates a full-blown URL with the underlying base class nsMsgMailNewsUrl properly initialised? Looking at my try push most of the failing tests seem to relate to the "mail to" URLs which show the errors mentioned in comment #21. The code is this: https://dxr.mozilla.org/comm-central/rev/a8eecfe6de793af00e98cb1488515199c5fb73fb/mailnews/compose/src/nsSmtpService.cpp#315 calling this: https://dxr.mozilla.org/comm-central/rev/a8eecfe6de793af00e98cb1488515199c5fb73fb/mailnews/compose/src/nsSmtpUrl.cpp#268 m_baseURL was intialised in the constructor, so how can it be null?
Flags: needinfo?(valentin.gosu)
Assignee | ||
Updated•6 years ago
|
Keywords: leave-open
Version: 60 → Trunk
Assignee | ||
Comment 25•6 years ago
|
||
OK, this clears up test_mailtoURL.js which still failed on the try. Let's see what else works.
Attachment #8960733 -
Attachment is obsolete: true
Comment 26•6 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #24) > (In reply to Valentin Gosu [:valentin] from comment #22) > > So, SetSpecInternal doesn't really need to mutate anything. You can just > > create a new mutator and SetSpec on that. > I think it doesn't really matter whether it mutates the old one or creates a > new one straight away. > > If you look at the constructor of nsMsgMailNewsUrl, it does > m_baseURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID); Oh, this is the problem. The deserialization code now instantiates a mutator when passed the CID for standardURL in order to be backwards compatible. Meaning the code here [1] will create a mutator for the cid of nsStandardURL. The call to read will create it in the mutator, then QueryInterface will act just like the finalizer. [1] https://searchfox.org/mozilla-central/rev/b29daa46443b30612415c35be0a3c9c13b9dc5f6/xpcom/io/nsBinaryStream.cpp#974 Problem is that now do_CreateInstance(NS_STANDARDURL_CONTRACTID) and all others (simpleURI, etc) return a mutator instead, and unless it's initialized by calling SetSpec for example, QIing it to nsIURI will fail and m_baseURL will be null. My recommendation is for SetSpecInternal/etc to always construct a new URI using the mutator. Bug 1442242 will make all the URI constructors private anyway.
Assignee | ||
Comment 27•6 years ago
|
||
Doing the same trick with the address book URL fixes more tests.
Attachment #8960791 -
Attachment is obsolete: true
Assignee | ||
Comment 28•6 years ago
|
||
OK, that does what was suggested. I'll leave this open to look into the other uses. How about rv = CallCreateInstance(kImapUrlCID, imapUrl); Does that need to be replaced? I guess LDAP is OK for now? https://dxr.mozilla.org/comm-central/rev/a8eecfe6de793af00e98cb1488515199c5fb73fb/ldap/xpcom/src/nsLDAPURL.cpp#40
Attachment #8960794 -
Attachment is obsolete: true
Assignee | ||
Comment 29•6 years ago
|
||
And we have plenty more, for example here: https://dxr.mozilla.org/comm-central/rev/a8eecfe6de793af00e98cb1488515199c5fb73fb/mailnews/base/util/nsMsgUtils.cpp#185
Comment 30•6 years ago
|
||
Pushed by mozilla@jorgk.com: https://hg.mozilla.org/comm-central/rev/481987fc6713 Create a new base URL in nsXXXUrl::SetSpecInternal(). rs=bustage-fix
Comment 31•6 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #28) > Created attachment 8960798 [details] [diff] [review] > 1447272-SetSpecInternal.patch (v4) > > OK, that does what was suggested. > > I'll leave this open to look into the other uses. > How about > rv = CallCreateInstance(kImapUrlCID, imapUrl); > Does that need to be replaced? Well, no. It would be great for maintainability if all URL implementations followed the same pattern, of using the mutator, but since it wasn't serializable, and I didn't change the way it's instantiated, it's OK for now. > I guess LDAP is OK for now? > https://dxr.mozilla.org/comm-central/rev/ > a8eecfe6de793af00e98cb1488515199c5fb73fb/ldap/xpcom/src/nsLDAPURL.cpp#40 That is OK. The contractID for the mutator still works.
Flags: needinfo?(valentin.gosu)
Comment 32•6 years ago
|
||
Comment on attachment 8960529 [details] [diff] [review] 1447272-remove-mutator-read.patch Review of attachment 8960529 [details] [diff] [review]: ----------------------------------------------------------------- Thanks.
Attachment #8960529 -
Flags: review+
Comment 33•6 years ago
|
||
Comment on attachment 8960798 [details] [diff] [review] 1447272-SetSpecInternal.patch (v4) Review of attachment 8960798 [details] [diff] [review]: ----------------------------------------------------------------- I'm not very happy about the window where m_baseURL is null between the constructor and the first SetSpecInternal() call, but if that is the right way now...
Attachment #8960798 -
Flags: review+
Comment 34•6 years ago
|
||
(In reply to :aceman from comment #33) > Comment on attachment 8960798 [details] [diff] [review] > 1447272-SetSpecInternal.patch (v4) > > Review of attachment 8960798 [details] [diff] [review]: > ----------------------------------------------------------------- > > I'm not very happy about the window where m_baseURL is null between the > constructor and the first SetSpecInternal() call, but if that is the right > way now... uninitialized isn't much better than null, IMO. This is why I'm making constructors private, so you are forced to use a mutator, and without proper error checking you get back a null URI.
Assignee | ||
Comment 35•6 years ago
|
||
We still have a crash in mailnews/jsaccount/test/unit/test_fooUrl.js, but the rest looks good so far.
Assignee | ||
Comment 36•6 years ago
|
||
Hmm, bug 1442242 already landed and bounced back. Will that affect the stuff mentioned in comment #28 and #29, #29 being: nsCOMPtr<nsIImapUrl> imapUrl = do_CreateInstance(kImapUrlCID, &rv); nsCOMPtr<nsIMailboxUrl> mailboxUrl = do_CreateInstance(kCMailboxUrl, &rv); and more?
Assignee | ||
Comment 37•6 years ago
|
||
I guess we're done here then, I filed bug 1447492 for mailnews/jsaccount/test/unit/test_fooUrl.js is crashing.
Status: REOPENED → RESOLVED
Closed: 6 years ago → 6 years ago
Keywords: leave-open
Resolution: --- → FIXED
Comment 38•6 years ago
|
||
(In reply to Jorg K (GMT+1) from comment #36) > Hmm, bug 1442242 already landed and bounced back. Will that affect the stuff > mentioned in comment #28 and #29, #29 being: > nsCOMPtr<nsIImapUrl> imapUrl = do_CreateInstance(kImapUrlCID, &rv); > nsCOMPtr<nsIMailboxUrl> mailboxUrl = do_CreateInstance(kCMailboxUrl, &rv); > and more? No. It only removes the constructors for gecko URI implementations. I don't think any of the TB URIs extend them, so it should be OK.
You need to log in
before you can comment on or make changes to this bug.
Description
•