Closed
Bug 851467
Opened 11 years ago
Closed 11 years ago
Thunderbird 17.0.3 crashes when calling createSmtpServer after createAccount for new profile
Categories
(MailNews Core :: Account Manager, defect)
Tracking
(thunderbird24-, thunderbird-esr17-)
RESOLVED
FIXED
Thunderbird 24.0
People
(Reporter: doubleaxe, Assigned: aceman)
References
(Blocks 1 open bug)
Details
(Keywords: crash, reproducible)
Crash Data
Attachments
(2 files, 2 obsolete files)
1.52 KB,
application/octet-stream
|
Details | |
3.36 KB,
patch
|
standard8
:
review+
|
Details | Diff | Splinter Review |
User Agent: Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14 Steps to reproduce: If extension tries to create new account and calls createAccount prior calling createSmtpServer, Thunderbird crashes. Simple test case listed below: function accountManagerTest() { var accman = Components.classes['@mozilla.org/messenger/account-manager;1'].getService(Components.interfaces.nsIMsgAccountManager); var smtp = Components.classes['@mozilla.org/messengercompose/smtp;1'].getService(Components.interfaces.nsISmtpService); accman.createAccount(); smtp.createSmtpServer(); } Also simple xpi reproducing issue attached to this report. To check install extension and press Tools->Account manager test. Thunderbird will crash. Actual results: Thunderbird crashes Expected results: No crash
Reporter | ||
Comment 1•11 years ago
|
||
Forgot to write: test case should be launched on clear newly created profile, where no accounts already exist.
Reporter | ||
Comment 3•11 years ago
|
||
Crash ID: bp-e77a9181-6af7-4f61-b705-7e11a2130315
Seems to crash in nsMsgAccountManager::GetDefaultAccount http://hg.mozilla.org/releases/comm-esr17/annotate/5967074c61d4/mailnews/base/src/nsMsgAccountManager.cpp#l851 . The usual flow we use in tests is to create the server first, then identity, then account and link them. But of course, it should not crash if this is not followed.
Product: Thunderbird → MailNews Core
Comment 5•11 years ago
|
||
Aha, so GetDefaultAccount checks for there being no account, but it doesn't account (pun intended) for the case of no incoming server.
Should it then fail somewhere starting at http://hg.mozilla.org/releases/comm-esr17/annotate/5967074c61d4/mailnews/base/src/nsMsgAccountManager.cpp#l822? Do we add a check of return value of account->GetIncomingServer ? (I have not yet tested the extension so can't confirm the crash.)
The attachment seems to be corrupt, not a zip file. Alexey, can you check it?
Neil, what about changing NS_ADDREF to NS_IF_ADDREF ? The m_defaultAccount can still be null in the case here. I see from the file history that this was changed some time in the past, but not sure why.
Flags: needinfo?(neil)
Alexey, are you able to build Thunderbird to test a C++ patch?
Assignee | ||
Comment 10•11 years ago
|
||
This prevents the crash for me. I made this scenario behave as when no account is found (in that case we return error, not NS_OK).
Assignee: nobody → acelists
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #725596 -
Flags: review?(neil)
Assignee | ||
Comment 11•11 years ago
|
||
I could reproduce the crash on Linux on trunk with the code from comment 0 put directly into TB.
Severity: normal → major
OS: Windows 7 → All
Hardware: x86_64 → All
Updated•11 years ago
|
Severity: major → critical
Reporter | ||
Comment 12•11 years ago
|
||
I don't know why, but test extension attachment was corrupted. First 32 bytes were stripped off. Uploading correct version.
Comment 13•11 years ago
|
||
Comment on attachment 725338 [details] Simple test extension That was caused by a bug in the MIME type auto-detection routine (bug 848457).
Attachment #725338 -
Attachment is obsolete: true
Flags: needinfo?(neil)
Assignee | ||
Comment 14•11 years ago
|
||
You mean the attachment corruption, not the bug :)
Comment 15•11 years ago
|
||
(In reply to aceman from comment #8) > Neil, what about changing NS_ADDREF to NS_IF_ADDREF ? The m_defaultAccount > can still be null in the case here. I see from the file history that this > was changed some time in the past, but not sure why. I see there was an outstanding NEEDINFO that I accidentally cancelled, but then I noticed that your patch had switched to throwing an exception anyway, which is probably what I would have suggested.
Reporter | ||
Comment 16•11 years ago
|
||
(In reply to :aceman from comment #9) > Alexey, are you able to build Thunderbird to test a C++ patch? I manually applied your patch to 17.0.3 and built it. It seems to work, no crashes on test extension. Also my real extension which creates mail accounts doesn't crash now, account created successfully.
Assignee | ||
Comment 17•11 years ago
|
||
(In reply to neil@parkwaycc.co.uk from comment #15) > I see there was an outstanding NEEDINFO that I accidentally cancelled, but > then I noticed that your patch had switched to throwing an exception anyway, > which is probably what I would have suggested. I left it at NS_ADDREF but covered the null case by a new early return. I added an assertion in case we still missed some case where the default can stay at null and would crash at the NS_IF_ADDREF. Can you review it now? (In reply to Alexey Ousov from comment #16) > I manually applied your patch to 17.0.3 and built it. It seems to work, no > crashes on test extension. Also my real extension which creates mail > accounts doesn't crash now, account created successfully. Thanks for the test. But in the extension make sure you create the server as soon as possible after the account and smtp server and link it to the account. We prevented the crash you found, but if you access the account in any way before it has a server you may trigger some other unexpected behaviour. Simply accounts are supposed to have servers so some code may rely on that without checking.
tracking-thunderbird-esr17:
--- → ?
Comment 18•11 years ago
|
||
Not tracking - this appears to be limited to extensions that call in a particular order (which afaict can be worked around), so not a significant issue.
Attachment #725596 -
Flags: review?(mbanner)
tracking-thunderbird24:
--- → ?
Comment 20•11 years ago
|
||
bp-e77a9181-6af7-4f61-b705-7e11a2130315 nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount**) 0 xul.dll nsMsgAccountManager::GetDefaultAccount mailnews/base/src/nsMsgAccountManager.cpp:851 1 xul.dll NS_InvokeByIndex_P xpcom/reflect/xptcall/src/md/win32/xptcinvoke.cpp:70 2 xul.dll XPCWrappedNative::CallMethod js/xpconnect/src/XPCWrappedNative.cpp:2367 3 xul.dll XPC_WN_GetterSetter js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1526 4 mozjs.dll js::InvokeKernel js/src/jsinterp.cpp:352 crashes do exist in the wild. looks like all are startup. some however have a different stack involving nsMessengerWinIntegration. example ... bp-8d016dea-29ce-40fc-95d6-eb1442130304 0 xul.dll nsMsgAccountManager::GetDefaultAccount mailnews/base/src/nsMsgAccountManager.cpp:851 1 xul.dll nsMessengerWinIntegration::SetupInbox mailnews/base/src/nsMessengerWinIntegration.cpp:1025 2 xul.dll nsMessengerWinIntegration::UpdateUnreadCount mailnews/base/src/nsMessengerWinIntegration.cpp:1097 3 xul.dll nsMessengerWinIntegration::OnItemIntPropertyChanged mailnews/base/src/nsMessengerWinIntegration.cpp:900 4 xul.dll nsMsgMailSession::OnItemIntPropertyChanged mailnews/base/src/nsMsgMailSession.cpp:133 5 xul.dll nsMsgDBFolder::NotifyIntPropertyChanged mailnews/base/util/nsMsgDBFolder.cpp:4926 6 xul.dll nsMsgDBFolder::UpdateSummaryTotals mailnews/base/util/nsMsgDBFolder.cpp:4100 7 xul.dll nsImapMailFolder::UpdateSummaryTotals mailnews/imap/src/nsImapMailFolder.cpp:1773 8 xul.dll nsImapMailFolder::GetDatabase mailnews/imap/src/nsImapMailFolder.cpp:614 9 xul.dll nsImapMailFolder::GetDBFolderInfoAndDB mailnews/imap/src/nsImapMailFolder.cpp:2076 10 xul.dll nsMsgDBFolder::ReadDBFolderInfo mailnews/base/util/nsMsgDBFolder.cpp:628 11 xul.dll nsMsgDBFolder::GetFlags mailnews/base/util/nsMsgDBFolder.cpp:1236 12 xul.dll nsImapMailFolder::AddSubfolderWithPath mailnews/imap/src/nsImapMailFolder.cpp:384 13 xul.dll nsImapMailFolder::CreateClientSubfolderInfo mailnews/imap/src/nsImapMailFolder.cpp:943 14 xul.dll nsImapMailFolder::GetSubFolders mailnews/imap/src/nsImapMailFolder.cpp:577 15 xul.dll nsMsgDBFolder::GetChildWithURI mailnews/base/util/nsMsgDBFolder.cpp:3485 16 xul.dll nsImapIncomingServer::GetExistingMsgFolder mailnews/imap/src/nsImapIncomingServer.cpp:3249 17 xul.dll nsImapIncomingServer::GetMsgFolderFromURI mailnews/imap/src/nsImapIncomingServer.cpp:3203 18 xul.dll nsSpamSettings::GetSpamFolderURI mailnews/base/src/nsSpamSettings.cpp:539 19 xul.dll nsSpamSettings::UpdateJunkFolderState mailnews/base/src/nsSpamSettings.cpp:424 20 xul.dll nsSpamSettings::Initialize mailnews/base/src/nsSpamSettings.cpp:414 21 xul.dll nsMsgIncomingServer::GetSpamSettings mailnews/base/util/nsMsgIncomingServer.cpp:2095 22 xul.dll nsMsgPurgeService::PerformPurge mailnews/base/src/nsMsgPurgeService.cpp:243
Crash Signature: [@ nsMsgAccountManager::GetDefaultAccount(nsIMsgAccount**) ]
Keywords: crashreportid
Comment 21•11 years ago
|
||
Not tracking for 24 either, due to pretty much the same reasons as 17. I would like to get this fixed though, but it appears to need Neil's input at the moment.
Comment 22•11 years ago
|
||
Comment on attachment 725596 [details] [diff] [review] patch Review of attachment 725596 [details] [diff] [review]: ----------------------------------------------------------------- ::: mailnews/base/src/nsMsgAccountManager.cpp @@ +799,5 @@ > } > } > } > > + NS_ASSERTION(m_defaultAccount, "Default account is null, when not expected!"); I think rather than assert and crash, we should just return a failure notification. That way, if we do happen to hit it, we'll at least attempt to do something that doesn't make TB disappear from the user. @@ +812,5 @@ > { > nsCOMPtr<nsIMsgAccount> oldAccount = m_defaultAccount; > m_defaultAccount = aDefaultAccount; > + (void) setDefaultAccountPref(aDefaultAccount); // it's ok if this fails > + (void) notifyDefaultServerChange(oldAccount, aDefaultAccount); // ok if notifications fail On both the lines here, you can remove the comments as the (void) is basically saying the same thing (i.e. its intentional).
Attachment #725596 -
Flags: review?(mbanner) → review-
Assignee | ||
Comment 23•11 years ago
|
||
OK, would this work for you?
Attachment #725596 -
Attachment is obsolete: true
Attachment #725596 -
Flags: review?(neil)
Attachment #766673 -
Flags: review?(mbanner)
Comment 24•11 years ago
|
||
Comment on attachment 766673 [details] [diff] [review] patch v2 Review of attachment 766673 [details] [diff] [review]: ----------------------------------------------------------------- Looks good, thanks.
Attachment #766673 -
Flags: review?(mbanner) → review+
Updated•11 years ago
|
Keywords: checkin-needed
Comment 25•11 years ago
|
||
https://hg.mozilla.org/comm-central/rev/9ff0c7ce1ea2
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: needinfo?(neil)
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 24.0
You need to log in
before you can comment on or make changes to this bug.
Description
•