User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:188.8.131.52) Gecko/20061205 Iceweasel/184.108.40.206 (Debian-220.127.116.11+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:
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.
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
Created attachment 256382 [details] [diff] [review]
call getPrefService in nsMsgAccountManager::GetIncomingServer
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 ?
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...
The .xpi can no longer be accessed.
Bienvenu, any thoughts on this? (not sure on the validity of this..)
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.
(no crashes in last 9 months)
Should the same (comment 5) be done in nsMsgAccount.cpp too? It seems the only file using similar approach.
Created attachment 590849 [details] [diff] [review]
patch per comment 5
Standard8, did you mean something like this?
Comment on attachment 590849 [details] [diff] [review]
patch per comment 5
Review of attachment 590849 [details] [diff] [review]:
@@ +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)
Created attachment 595442 [details] [diff] [review]
patch with nit
With review from standard8.
Checked in: http://hg.mozilla.org/comm-central/rev/e0ccaae60f48