Closed Bug 496582 Opened 16 years ago Closed 3 years ago

nsCocoaWindow_NSWindow_sendEvent should not assume |self| will remain valid

Categories

(Core :: Widget: Cocoa, defect)

1.9.0 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME
Tracking Status
status1.9.1 --- wontfix

People

(Reporter: stuart.morgan+bugzilla, Unassigned)

Details

(Keywords: fixed1.9.0.12, regression)

Attachments

(1 file, 3 obsolete files)

An early crash from Camino 2.0b3: http://crash-stats.mozilla.com/report/index/c67985f4-f77e-4c83-bb33-b08d82090604 shows a crash under _freedHandler in http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/widget/src/cocoa/nsCocoaWindow.mm&rev=1.151&mark=2155#2155 Given that, it looks like it's not safe to assume that the window will still be valid after [self nsCocoaWindow_NSWindow_sendEvent:anEvent]; If nothing else there should be a [self retain]; just before calling through, and a [self release] at the end of the method (I'd rather it not be an autorelease, since there should be as little impact on object lifetimes as possible). Since this is a regression caused by the swizzling, I'd really like to see it fixed in 1.9.0.x
Flags: wanted1.9.0.x?
> there should be a [self retain]; just before calling through, and a > [self release] at the end of the method In light of your stack, I think this is a reasonable suggestion. I'll post a patch that does this. This bug isn't "caused by method swizzling" -- it's caused by the assumption that an NSWindow will always be valid after a call to [NSWindow sendEvent:], which your stack shows to be false.
(In reply to comment #1) It helps if you don't misquote me. I did not say "caused by method swizzling", I said "caused by *the* swizzling", as in "caused by the swizzling I just mentioned two sentences ago, so I assume the reference is painfully clear".
Attached patch Trunk patch (obsolete) — Splinter Review
Attachment #381830 - Flags: review?(joshmoz)
Attached patch 1.9.0-branch patch (obsolete) — Splinter Review
Attachment #381831 - Flags: review?(joshmoz)
Comment on attachment 381830 [details] [diff] [review] Trunk patch Maybe use nsAutoRetainCocoaObject?
> Maybe use nsAutoRetainCocoaObject? Fine with me. New patch coming up shortly.
Attachment #381830 - Attachment is obsolete: true
Attachment #381855 - Flags: review?(joshmoz)
Attachment #381830 - Flags: review?(joshmoz)
Attachment #381855 - Flags: review?(joshmoz) → review+
Comment on attachment 381831 [details] [diff] [review] 1.9.0-branch patch We should probably do autoretain on 1.9.0 too, adding all necessary code.
Attachment #381831 - Flags: review?(joshmoz)
Attachment #381855 - Flags: superreview?(roc)
Attachment #382323 - Attachment description: 1.9.0-branch patch v1.1 (follow Josh → 1.9.0-branch patch v1.1 (follow Josh's suggestion)
Attachment #382323 - Flags: review?(joshmoz)
Attachment #382323 - Flags: review?(joshmoz) → review+
Attachment #382323 - Flags: superreview?(roc)
Attachment #381855 - Flags: superreview?(roc) → superreview+
Attachment #382323 - Flags: superreview?(roc) → superreview+
Attachment #381831 - Attachment is obsolete: true
Comment on attachment 381855 [details] [diff] [review] Trunk patch v1.1 (follow Josh's suggestion) Oops. This has been made obsolete by the patch for bug 178324, which got rid of nsCocoaWindow_NSWindow_sendEvent.
Attachment #381855 - Attachment is obsolete: true
Attachment #382323 - Flags: approval1.9.0.12?
Is there anywhere else this patch should land, like 1.9.1?
Assignee: nobody → smichaud
It should probably also land on the 1.9.1 branch.
Flags: wanted1.9.1.x+
Flags: wanted1.9.0.x?
Flags: wanted1.9.0.x+
Comment on attachment 382323 [details] [diff] [review] 1.9.0-branch patch v1.1 (follow Josh's suggestion) Approved for 1.9.0.12, a=dveditz for release-drivers
Attachment #382323 - Flags: approval1.9.0.12? → approval1.9.0.12+
Comment on attachment 382323 [details] [diff] [review] 1.9.0-branch patch v1.1 (follow Josh's suggestion) Landed on the 1.9.0 branch: Checking in widget/src/cocoa/nsCocoaWindow.mm; /cvsroot/mozilla/widget/src/cocoa/nsCocoaWindow.mm,v <-- nsCocoaWindow.mm new revision: 1.152; previous revision: 1.151 done
Status: NEW → RESOLVED
Closed: 16 years ago
Keywords: fixed1.9.0.12
Resolution: --- → FIXED
This isn't really RESOLVED FIXED since it needs to land on 1.9.1 as well and Bugzilla doesn't really have a way to say "this bug is for two branches but not for trunk". So I tend to prefer such bugs staying open until they're fixed in both places.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Fixed this in 1.9.0.12, so we should fix it in 1.9.1.x, maybe 1.9.1.1?
Flags: blocking1.9.1.1?
Not going to block 1.9.1.1 on this, but Steven if you can work up a 1.9.1 patch, we'll look at it for approval.
Flags: blocking1.9.1.1?
Flags: wanted1.9.1.x+
Assignee: smichaud → nobody
Status: REOPENED → RESOLVED
Closed: 16 years ago3 years ago
Resolution: --- → FIXED
Resolution: FIXED → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: