crash in [@ nsMsgAccountManager::GetIncomingServer] when getPrefService has not been called

RESOLVED FIXED in Thunderbird 13.0

Status

MailNews Core
Account Manager
--
critical
RESOLVED FIXED
11 years ago
6 years ago

People

(Reporter: arno renevier, Assigned: aceman)

Tracking

({crash})

Trunk
Thunderbird 13.0
x86
All
crash

Firefox Tracking Flags

(Not tracked)

Details

(crash signature, URL)

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061205 Iceweasel/2.0.0.1 (Debian-2.0.0.1+dfsg-2)
Build Identifier: version 3 alpha 1 (20070225)

If nsMsgAccountManager::GetIncomingServer is called, but m_pref is null, 
rv = m_prefs->GetCharPref(serverPref.get(), getter_Copies(serverType));
makes thunderbird crash
This can happen if you have an application shipped as an extension for thunderbird (application which you call with thunderbird -chrome chrome://blabla/content), and first line of your script is for example:

Components.classes["@mozilla.org/messenger/account-manager;1"].
        createInstance(Components.interfaces.nsIMsgAccountManager).
        getIncomingServer('server1');

I've attached a .xpi for testcase.

My suggestion is to add a call to nsMsgAccountManager::getPrefService in nsMsgAccountManager::GetIncomingServer.
I'll attach this solution as a patch.

Reproducible: Always

Steps to Reproduce:
1. install .xpi at http://ffsearchplugins.free.fr/bugzilla/nsimsgaccountmanager-crash.xpi
2. start thunderbird with thunderbird -chrome chrome://crash/content/crash.xul
Actual Results:  
crash

Expected Results:  
no crash
(Reporter)

Comment 1

11 years ago
Created attachment 256382 [details] [diff] [review]
call getPrefService in nsMsgAccountManager::GetIncomingServer

Updated

11 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: crash
(Reporter)

Comment 2

11 years ago
Another possibility would be to call getPrefService once in nsMsgAccountManager constructor instead of calling it in each method that needs it. That ensures we don't have the same problem on other methods. Are there any drawbacks ?

Comment 3

11 years ago
it can fail and constructors have no way of indicating failure.

so you can be right back where you started. if you don't mind crashing again next time, then it doesn't have any drawbacks...

Updated

9 years ago
Assignee: mscott → nobody
The .xpi can no longer be accessed.

Bienvenu, any thoughts on this? (not sure on the validity of this..)
Attachment #256382 - Attachment is patch: true
Attachment #256382 - Attachment mime type: application/octet-stream → text/plain
The bug is essentially still valid. Given nsMsgAccountManager is a service and has an Init function, I would suggest that the pref service is initialised once in the Init function, and the getPrefService function is dropped.
Keywords: helpwanted

Updated

9 years ago
Summary: crash in nsMsgAccountManager::GetIncomingServer when getPrefService has not been called → crash in [@ nsMsgAccountManager::GetIncomingServer] when getPrefService has not been called
Crash Signature: [@ nsMsgAccountManager::GetIncomingServer]
(no crashes in last 9 months)
Whiteboard: [patchlove] [has draft patch]
(Assignee)

Updated

6 years ago
Assignee: nobody → acelists
(Assignee)

Comment 7

6 years ago
Should the same (comment 5) be done in nsMsgAccount.cpp too? It seems the only file using similar approach.
Assignee: acelists → nobody
Status: NEW → ASSIGNED
Component: Account Manager → Account Manager
Product: Thunderbird → MailNews Core
QA Contact: account-manager → account-manager
Whiteboard: [patchlove] [has draft patch]
Version: unspecified → Trunk
(Assignee)

Comment 8

6 years ago
Created attachment 590849 [details] [diff] [review]
patch per comment 5

Standard8, did you mean something like this?
Assignee: nobody → acelists
Attachment #256382 - Attachment is obsolete: true
Attachment #590849 - Flags: review?(mbanner)
Comment on attachment 590849 [details] [diff] [review]
patch per comment 5

Review of attachment 590849 [details] [diff] [review]:
-----------------------------------------------------------------

::: mailnews/base/src/nsMsgAccountManager.cpp
@@ +1273,5 @@
> +   * to add to the existing accounts list.
> +   */
> +  nsCOMPtr<nsIPrefBranch> defaultsPrefBranch;
> +  rv = prefservice->GetDefaultBranch(MAILNEWS_ROOT_PREF, getter_AddRefs(defaultsPrefBranch));
> +  NS_ENSURE_SUCCESS(rv,rv);

nit: as you're touching these lines, please insert a space after the comma (several places in this section)
Attachment #590849 - Flags: review?(mbanner) → review+
(Assignee)

Comment 10

6 years ago
Created attachment 595442 [details] [diff] [review]
patch with nit

With review from standard8.
Attachment #590849 - Attachment is obsolete: true
Attachment #595442 - Flags: review+
(Assignee)

Updated

6 years ago
Keywords: helpwanted → checkin-needed
Checked in: http://hg.mozilla.org/comm-central/rev/e0ccaae60f48
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 13.0
You need to log in before you can comment on or make changes to this bug.