Closed Bug 192024 Opened 23 years ago Closed 23 years ago

Crash in nsComposerCommandsUpdater::SelectionIsCollapsed()

Categories

(Core :: DOM: Editor, defect)

defect
Not set
critical

Tracking

()

VERIFIED FIXED

People

(Reporter: mkaply, Assigned: mkaply)

Details

(Keywords: crash)

Attachments

(1 file, 2 obsolete files)

On reloading the testcase in http://bugzilla.mozilla.org/show_bug.cgi?id=191994 multiple times, I crashed. I investigated it and found this code in nsComposerCommandsUpdater: http://lxr.mozilla.org/seamonkey/source/editor/composer/src/nsComposerCommandsUpdater.cpp#371 if (NS_SUCCEEDED(mDOMWindow->GetSelection(getter_AddRefs(domSelection)))) { PRBool selectionCollapsed = PR_FALSE; domSelection->GetIsCollapsed(&selectionCollapsed); return selectionCollapsed; } The problem is that GetSelection can return NS_OK even though domSelection is NULL. We need a NULL check against domSelection before dereferencing. See: http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#3455 this is where GetSelection ends up. Note that NS_OK is returned in multiple cases without setting aSelection.
Severity: major → critical
Keywords: crash
Attached patch Fix for problem (obsolete) — — Splinter Review
Add nullcheck for domSelection. With this patch, I am able to do multiple reloads, etc. without crashing.
Attachment #113596 - Flags: review?(brade)
Comment on attachment 113596 [details] [diff] [review] Fix for problem r=brade if you add an assertion for the null dom selection (Kin already gave an sr= to a patch like this but he requested the assertion)
Attachment #113596 - Flags: superreview?(kin)
Attachment #113596 - Flags: review?(brade)
Attachment #113596 - Flags: review+
-->mkaply since he has patch
Assignee: jfrancis → mkaply
Comment on attachment 113596 [details] [diff] [review] Fix for problem sr=kin@netscape.com You can add an NS_WARNING(), my concern is that an assertion will be too annoying in win32 debug builds. The underlying problem is that the presShell is disappearing out from underneath us because the document/page is hidden. I don't remember all the details of why the editor doesn't hold a strong reference to the PresShell though ... it was probably to break some dependency cycle.
Attachment #113596 - Flags: superreview?(kin) → superreview+
Attached patch Patch with NS_WARNING (obsolete) — — Splinter Review
I split out the null check so I could add an NS_WARNING
Attachment #113596 - Attachment is obsolete: true
Comment on attachment 113602 [details] [diff] [review] Patch with NS_WARNING r=brade if you move the curly brace on this line to a new line (to be consistent with other places): + if (domSelection) {
Attachment #113602 - Flags: superreview?(kin)
Attachment #113602 - Flags: review+
Sorry, may I ask a dumb question -- why domSelection checked for null after GetSelection call? I always think that more reasonable would be made check before usage, or I miss something?
Comment on attachment 113602 [details] [diff] [review] Patch with NS_WARNING I actually prefer your 1st patch, the warning could've been added after the |if| block, just before the return, since we should never really get there.
Attachment #113602 - Flags: superreview?(kin) → superreview-
Attached patch One more time — — Splinter Review
Original patch with NS_WARNING when we return FALSE
Attachment #113602 - Attachment is obsolete: true
Comment on attachment 113604 [details] [diff] [review] One more time r=brade
Attachment #113604 - Flags: superreview?(kin)
Attachment #113604 - Flags: review+
Attachment #113604 - Flags: superreview?(kin) → superreview+
Comment on attachment 113604 [details] [diff] [review] One more time This is a crasher that we would like to get into 1.3b if we could.
Attachment #113604 - Flags: approval1.3b?
Comment on attachment 113604 [details] [diff] [review] One more time a=asa (on behalf of drivers) for checkin to 1.3beta.
Attachment #113604 - Flags: approval1.3b? → approval1.3b+
Fix checked in.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
using today's builds, i don't crash when reloading the test case in bug 191994.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: