Closed Bug 1022042 Opened 10 years ago Closed 10 years ago

compareVariants in the test plugin leaks |identifiers|

Categories

(Core Graveyard :: Plug-ins, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla33

People

(Reporter: mccr8, Assigned: james, Mentored)

References

(Blocks 1 open bug)

Details

(Whiteboard: [lang=c++] [good first bug])

Attachments

(2 files, 1 obsolete file)

Attached file leaking stacks
The NPVariantType_Object case calls into NPN_Enumerate, which allocates a buffer for identifiers, but the test plugin fails to free it.
Blocks: LSan
Andrew, can you add which test this happens in?
Flags: needinfo?(continuation)
The affected code is here:
http://hg.mozilla.org/mozilla-central/annotate/9dc0ffca10f4/dom/plugins/test/testplugin/nptest.cpp#l2217

The note in the documentation mentions what cleanup is expected:
https://developer.mozilla.org/en-US/docs/NPN_Enumerate
Whiteboard: [mentor=gfritzsche] [lang=c++] [good first bug]
(In reply to Georg Fritzsche [:gfritzsche] from comment #1)
> Andrew, can you add which test this happens in?

I'm not sure offhand, but I can bisect it at some point.
I want to solve this bug.It will be my first bug.Please help me.
Hi Anmol,

comment 2 shows the section of the code that is affected and links to the documentation.
If you don't have a working Firefox build yet, see here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions

Let me know if there are more specific questions (and feel free to drop me an e-mail or talk on IRC if you prefer).
(In reply to Georg Fritzsche [:gfritzsche] from comment #1)
> Andrew, can you add which test this happens in?

This happens in some subtest of Mochitest-other that looks like it just runs things in /dom/plugins/test/mochitest/?  I'm not sure what that is.
Flags: needinfo?(continuation)
Attached patch test-plugin-leaks-fix.patch (obsolete) — Splinter Review
Is this what you're looking for? I haven't tested as I'm not familiar yet with how to go about that part.

Were the leaks detected from the valgrind tests? Or do the mochitests catch them too? I'm a little confused on that part.
Attachment #8441562 - Flags: review?(georg.fritzsche)
> Were the leaks detected from the valgrind tests? Or do the mochitests catch them too? I'm a little confused on that part.

This was detected by running Mochitests with LeakSanitizer, which is a special mode of our AddressSanitizer builds.  It hasn't landed yet.  (Bug 988041)
Mentor: georg.fritzsche
Whiteboard: [mentor=gfritzsche] [lang=c++] [good first bug] → [lang=c++] [good first bug]
Comment on attachment 8441562 [details] [diff] [review]
test-plugin-leaks-fix.patch

Review of attachment 8441562 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good, thanks James!
It would be great if you can test this. We were missing information on it in this bug, let me fix this.

You first need to have an ASAN build:
https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Firefox_and_Address_Sanitizer#Manual_Build

Then you should check out the LSAN section Andrew added:
https://developer.mozilla.org/en-US/docs/Mozilla/Testing/Firefox_and_Address_Sanitizer#LeakSanitizer

Now, without your patch applied, one of these test-runs should trigger the issue Andrew reported:
> mach mochitest-plain dom/plugins
> mach mochitest-chrome dom/plugins

Running again with your patch applied, the problem should be resolved.

Let me know if there are any issues and i'll check it out.
Attachment #8441562 - Flags: review?(georg.fritzsche) → feedback+
I can also just test this patch myself.  Unless you are on Linux, ASAN builds are either hard (OSX) or impossible (Windows).
Assignee: nobody → james
I can try it in a VM. Thanks for the links.
It looks like the leak is actually happening with mochitest-plugins, which seems to be a version of dom/plugins that runs with in-process plugins.  I wasn't able to figure out how to run it locally in the right way.
Andrew, maybe you can just do a push with the fix and see if it is fine now?

Alternatively, i think we could just override it locally by adding:
> user_pref("dom.ipc.plugins.enabled.i386", false);
> user_pref("dom.ipc.plugins.enabled.x86_64", false);
... to the testing profiles:
http://mxr.mozilla.org/mozilla-central/source/testing/profiles/prefs_general.js
Status: NEW → ASSIGNED
Flags: needinfo?(continuation)
Yeah, I can just check it at some point in the next day or two.
Flags: needinfo?(continuation)
Ok, I finally got around to doing a test run for this.  We'll see how it goes:
  https://tbpl.mozilla.org/?tree=Try&rev=5d2aba8e2226
Since LSan has now landed, if this works, please incorporate the removal of the suppression for this so we can catch any regressions in the future.  That would just be this little patch:
  https://hg.mozilla.org/try/rev/ba4c8c806393
Yep, it looks good to me, this patch fixed the leak.
Comment on attachment 8441562 [details] [diff] [review]
test-plugin-leaks-fix.patch

Thanks for checking it out Andrew.

James, sorry for the turn-around time here - this should be landing now after Benjamin signed it off.
Could you upload a patch with a suitable commit message?
There are some details here: https://developer.mozilla.org/en-US/docs/Mercurial_FAQ#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3F
Attachment #8441562 - Flags: review?(benjamin)
Attachment #8441562 - Attachment is obsolete: true
Attachment #8441562 - Flags: review?(benjamin)
Attachment #8445165 - Flags: review?(georg.fritzsche)
Attachment #8445165 - Flags: review?(benjamin)
Comment on attachment 8445165 [details] [diff] [review]
fix-compareVariants-leak.patch

Review of attachment 8445165 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks, that looks good. I'm no actual peer for plugins code so just feedback+ from me.
Attachment #8445165 - Flags: review?(georg.fritzsche) → feedback+
Attachment #8445165 - Flags: review?(benjamin) → review+
https://hg.mozilla.org/mozilla-central/rev/86d027848ae0
https://hg.mozilla.org/mozilla-central/rev/d358bea25531
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
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: