Closed Bug 317012 Opened 19 years ago Closed 18 years ago

Crash in Release() in nsJavaXPTCStub::FinalizeJavaParams()

Categories

(Core Graveyard :: Java to XPCOM Bridge, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jhpedemonte, Assigned: jhpedemonte)

Details

(Keywords: fixed1.8.0.1, fixed1.8.1)

Attachments

(1 file)

Crashing in |nsJavaXPTCStub::FinalizeJavaParams()| due to over-aggressive Release() of xpcom object.  Specifically, this line:

     } else if (!isXPTCStub) { // if is native XPCOM object
       xpcom_obj->Release();
     }
Attached patch patchSplinter Review
The |xpcom_obj->Release();| was a bad attempt (I think) at handling the refcnt of xpcom objects for 'inout' params.  If the xpcom object that is returned by the method call is different than the object that was originally passed in, then the original xpcom object needs to be released.  This patch does it better.
Comment on attachment 203537 [details] [diff] [review]
patch

Shaver, does my description above about handling 'inout' params seem legit?
Attachment #203537 - Flags: review?(shaver)
Honestly, inout parameters always make me write down a bunch of use cases and test them out in my head.  Your reasoning sounds sane to me, as an optimization of always doing NS_IF_ADDREF(newval); NS_IF_RELEASE(oldval);, but it still feels weird for a callee to be dropping a reference on an argument.

I think you want a second opinion!
Checked in to trunk to fix crash for now.  I'll keep this open to get more input.
Attachment #203537 - Flags: review?(shaver)
Darin, what do you think of this patch?  See comments #1 and #3.
Fixed on MOZILLA_1_8_BRANCH and MOZILLA_1_8_0_BRANCH.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: