Closed Bug 1513826 Opened 7 years ago Closed 7 years ago

Crash in nsImapService::FetchMimePart with FiltaQuilla add-on

Categories

(MailNews Core :: Networking: IMAP, defect)

x86
All
defect
Not set
critical

Tracking

(thunderbird_esr6069+ fixed, thunderbird_esr6868+ fixed, thunderbird69 fixed, thunderbird70 fixed)

RESOLVED FIXED
Thunderbird 70.0
Tracking Status
thunderbird_esr60 69+ fixed
thunderbird_esr68 68+ fixed
thunderbird69 --- fixed
thunderbird70 --- fixed

People

(Reporter: wsmwk, Assigned: jorgk-bmo)

Details

(Keywords: crash)

Crash Data

Attachments

(1 file)

Axel, do you see this in any of the FiltaQuilla reports? This crash first appears with 60.3.0 This bug was filed from the Socorro interface and is report bp-7030048d-08d8-473f-b507-7c8c20181107. ============================================================= Top 10 frames of crashing thread: 0 xul.dll nsImapService::FetchMimePart comm/mailnews/imap/src/nsImapService.cpp:400 1 xul.dll nsMessenger::SaveAttachment comm/mailnews/base/src/nsMessenger.cpp:730 2 xul.dll nsMessenger::DetachAttachmentsWOPrompts comm/mailnews/base/src/nsMessenger.cpp:650 3 xul.dll NS_InvokeByIndex xpcom/reflect/xptcall/md/win32/xptcinvoke_asm_x86_msvc.asm:54 4 xul.dll XPCWrappedNative::CallMethod js/xpconnect/src/XPCWrappedNative.cpp:1234 5 xul.dll js::detail::CopyScript js/src/vm/JSScript.cpp:3661 6 xul.dll JS::GCVector<JS::Value, 8, js::TempAllocPolicy>::trace js/public/GCVector.h:136 7 xul.dll XPC_WN_CallMethod js/xpconnect/src/XPCWrappedNativeJSOps.cpp:913 8 xul.dll XPC_WN_CallMethod js/xpconnect/src/XPCWrappedNativeJSOps.cpp:913 9 xul.dll js::InternalCallOrConstruct js/src/vm/Interpreter.cpp:468 ============================================================= bp-5803845-5979-4b24-9e08-f97c30181203 bp-201ca0b2-7fdf-412b-89b1-bcca20181127
Assignee: nobody → jorgk
Status: NEW → ASSIGNED
Attachment #9084569 - Flags: review?(mkmelin+mozilla)
Comment on attachment 9084569 [details] [diff] [review] 1513826-fix-crash.patch Review of attachment 9084569 [details] [diff] [review]: ----------------------------------------------------------------- LGTM, r=mkmelin
Attachment #9084569 - Flags: review?(mkmelin+mozilla) → review+
Comment on attachment 9084569 [details] [diff] [review] 1513826-fix-crash.patch Pretty rare crash, some add-on must be calling this with a "bad" URL.
Attachment #9084569 - Flags: approval-comm-esr68?
Attachment #9084569 - Flags: approval-comm-beta+

(In reply to Jorg K (GMT+2) from comment #3)

Comment on attachment 9084569 [details] [diff] [review]
1513826-fix-crash.patch

Pretty rare crash, some add-on must be calling this with a "bad" URL.

Interesting, I am getting quite a few reports on this, how would the following code generate bad URLs? Are you talking about bad folder paths?

{
this.msgURI = aMsgHdr.folder.generateMessageURI(aMsgHdr.messageKey);
this.attachments = aMimeMessage.allAttachments;
let messenger = Cc["@mozilla.org/messenger;1"].createInstance(Ci.nsIMessenger);

if (this.attachments.length > 0) {
  let msgURIs = [],
      contentTypes = [],
      urls = [],
      displayNames = [];
  for (let j = 0; j < this.attachments.length; j++) {
    let attachment = this.attachments[j];
    msgURIs.push(this.msgURI);
    contentTypes.push(attachment.contentType);
    urls.push(attachment.url);
    displayNames.push(attachment.name);
    util.logDebug("Detach attachment [" + j + "] to " + uniqueFile.path + 
        "...\n msgURI=" + this.msgURI + 
        "\n att.url=" + attachment.url +
        "\n att.ncontentType=" + attachment.contentType)
    
  }
  messenger.detachAttachmentsWOPrompts(this.directory, this.attachments.length,
                          contentTypes, urls, displayNames, msgURIs, null);
}

}

I can't see how the code you pasted into comment #4 is relevant. It doesn't show a call to nsImapService::FetchMimePart() so I can't see which URL you're passing in.

In general, the nsIURI passed into the function is QI'ed to nsIMsgMailNewsUrl, so if it doesn't implement that interface, it will crash. With the patch, it will return an error. So if you call that function from your add-on(s), the least you can do is to dump out the .spec of the nsIURI before the call so we can see what gets passed in there. Surely something link file: or http(s): URLs are not nsIMsgMailNewsUrls.

Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/67b687a5aad6
Don't crash in nsImapService::FetchMimePart() if URL passed in can't be QI'ed. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED

(In reply to Jorg K (GMT+2) from comment #5)

I can't see how the code you pasted into comment #4 is relevant. It doesn't show a call to nsImapService::FetchMimePart() so I can't see which URL you're passing in.

In general, the nsIURI passed into the function is QI'ed to nsIMsgMailNewsUrl, so if it doesn't implement that interface, it will crash. With the patch, it will return an error. So if you call that function from your add-on(s), the least you can do is to dump out the .spec of the nsIURI before the call so we can see what gets passed in there. Surely something link file: or http(s): URLs are not nsIMsgMailNewsUrls.

It calls messenger.detachAttachmentsWOPrompts, which is part of the original stack trace:

0 xul.dll nsImapService::FetchMimePart comm/mailnews/imap/src/nsImapService.cpp:400
1 xul.dll nsMessenger::SaveAttachment comm/mailnews/base/src/nsMessenger.cpp:730
2 xul.dll nsMessenger::DetachAttachmentsWOPrompts comm/mailnews/base/src/nsMessenger.cpp:650

Unrelated: The NNTP and mailbox equivalents QI to nsIMsgMailNewsUrl straight away and return an error if unsuccessful:
https://searchfox.org/comm-central/rev/99e635c4517ff1689d25f01b41f0753160abf7ac/mailnews/local/src/nsMailboxService.cpp#235
https://searchfox.org/comm-central/rev/99e635c4517ff1689d25f01b41f0753160abf7ac/mailnews/news/src/nsNntpService.cpp#378
So this is the right fix.

Looking at your call stack, the aURI parameter of nsImapService::FetchMimePart() is a URI produced from the const nsACString &aURL, parameter passed into nsMessenger::SaveAttachment() (nsMessenger.cpp:730) and that comes from the first of the URL strings passed into nsMessenger::DetachAttachmentsWOPrompts() (nsMessenger.cpp:650).

So in your code that would be the urls variable which comes from attachment.url. So I guess that will fail big time if the attachment was detached, since than this will be a file: URL or it was a so-called "external" attachment (mainly used in feeds) which is a http(s): URL.

Dump out your urls variable.

Target Milestone: --- → Thunderbird 70.0

I'm wondering, if this crash could be related to my still existing problems and trials in upgrading the AttachmentsExtractor extension to "AttachmentExtractor Continued". In my tests Thunderbird crashes dependent on my try and error trials to fix a function to fetchMimeParts.

lines 433 and following:
https://gitlab.com/ThunderbirdMailDE/attachment-extractor-continued/blob/2.0a1-20190810/chrome/content/aec_js_messenger.js#L433

Attachment #9084569 - Flags: approval-comm-esr68? → approval-comm-esr68+

TB 60.9 ESR:
https://hg.mozilla.org/releases/comm-esr60/rev/448d166534091217fbc9e887025eceec12eefee4
great stuff - this will throw for a proper stack trace? I will add the URL parameter to my catch.

This will stop the crash. The function will return an error and it's likely that you'll see that as a throw in JS code.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: