Closed Bug 278113 Opened 20 years ago Closed 20 years ago

Handling 'out' params incorrectly

Categories

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

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jhpedemonte, Assigned: jhpedemonte)

Details

Attachments

(2 files)

Created a testcase that calls a function with an 'out' param which crashes in
nsJavaWrapper.  The problem is that in SetupParams, I use aVariant.ptr, but in
FinalizeParams, I reference aVariant.val.p.  Need to be consistent.
Attached patch patchSplinter Review
Turns out there were many problems with parameter handling, in addition to the
inconsistency mentioned above:
- Shouldn't hold Java array and string contents across invocations.  For
example, calling GetIntArrayElements() in SetupParams(), then invoking the
function, and finally calling ReleaseIntArrayElements() in FinalizeParams() is
wrong.	This pins the memory of that array in the JVM and doesn't allow it to
me moved or garbage collected, if necessary.  This patch uses more efficient
functions and does not hold any JVM memory across function invocations.
- Currently doesn't take into account that the caller can pass in null for
'inout', 'out', and 'retval' params.  This fixes that.
- Patch also makes similar changes in nsJavaXPTCStub.
- Always need to call ReleaseStringChars/ReleaseArrayElements, no matter if
isCopy is TRUE or FALSE.
Attached patch patch (diff -w)Splinter Review
Attachment #171049 - Flags: review?(darin)
Comment on attachment 171049 [details] [diff] [review]
patch (diff -w)

r=darin
Attachment #171049 - Flags: review?(darin) → review+
Checked in to trunk.  -> FIXED
Status: NEW → RESOLVED
Closed: 20 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: