Last Comment Bug 725603 - Leak in cuddlefish.js (with add-on Copy Tiny Url 0.4), many compartments system principal
: Leak in cuddlefish.js (with add-on Copy Tiny Url 0.4), many compartments sys...
Status: RESOLVED FIXED
[MemShrink:P3]
: mlk
Product: Add-on SDK
Classification: Client Software
Component: General (show other bugs)
: unspecified
: x86 Windows XP
: -- normal with 1 vote (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
Depends on: 724433
Blocks: LeakyAddons ZombieCompartments
  Show dependency treegraph
 
Reported: 2012-02-09 02:43 PST by Sebastian H. [:aryx][:archaeopteryx]
Modified: 2012-04-12 11:51 PDT (History)
7 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
copy tiny url 0.4 (136.67 KB, application/octet-stream)
2012-02-09 02:43 PST, Sebastian H. [:aryx][:archaeopteryx]
no flags Details
about:memory?verbose content with cuddlefish.js leak (114.76 KB, text/plain)
2012-02-09 02:46 PST, Sebastian H. [:aryx][:archaeopteryx]
no flags Details

Description Sebastian H. [:aryx][:archaeopteryx] 2012-02-09 02:43:10 PST
Created attachment 595692 [details]
copy tiny url 0.4

Firefox 10.0 32-bit Windows XP SP 3
Firefox Nightly 2012-02-08 Windows XP SP 3

If you install the Copy Tiny Url add-on in version 0.4 (see attachment), there are many compartments System Principal even after disabling the add-on, nightly blames cuddlefish.js for these.

Steps to reproduce:
1. Create a new profile.
2. Install the add-on.
3. Open the add-on manager, disable the add-on.
4. Open about:memory?verbose and close all other tabs.
5. Click 'Minimize memory usage'.

Actual result:
Still many compartments like this:
 compartment([System Principal], resource://jid1-epxk6cb8p5cx9w-at-jetpack/api-utils/lib/cuddlefish.js, 0x55b0000)

Add-on SDK version is 1.4.3

The main.js contains this:

var data = require("self").data;
var Request = require("request").Request;
const tabs = require("tabs");
let clipboard = require("clipboard");
var copy_tinyurl = {
    onTrack: function (window) {
        var doc = window.document;
        if (doc.documentElement.getAttribute("windowtype") !== "navigator:browser") return;
        // Modify the window!   
        if (doc.getElementById("urlbar") !== null && doc.getElementById("copy_tinyurl_icon") === null) {
            var urlbar = doc.getElementById("urlbar");
            var urlbarIcons = doc.getElementById("urlbar-icons");
            var copy_tinyurl_icon = doc.createElement('a');
            copy_tinyurl_icon.id = "copy_tinyurl_icon";
            copy_tinyurl_icon.class = "urlbar-icon";
            copy_tinyurl_icon.hidden = false;
            copy_tinyurl_icon.style.display = "inline-block";
            copy_tinyurl_icon.style.width = "16px";
            copy_tinyurl_icon.style.height = "16px";
            copy_tinyurl_icon.style.background = "url(" + data.url("icon-16.png") + ")";
            copy_tinyurl_icon.onclick = function () {
                if (tabs.activeTab.url.indexOf("http://") == 0 || tabs.activeTab.url.indexOf("https://") == 0) {
                    Request({
                        url: "http://tinyurl.com/api-create.php?url=" + encodeURIComponent(tabs.activeTab.url),
                        onComplete: function (response) {
                            clipboard.set(response.text);
                            urlbar.value = response.text;
 
                        }
                    }).get();
 
                }
 
            }
 
 
            urlbarIcons.appendChild(copy_tinyurl_icon);
        }
    },
    onUntrack: function (window) {
        // Clean up
        var doc = window.document;
        if (doc.documentElement.getAttribute("windowtype") !== "navigator:browser") return;
        // Modify the window!  
        if (doc.getElementById("copy_tinyurl_icon") !== null) {
            var copy_tinyurl_icon = doc.getElementById("copy_tinyurl_icon");
            copy_tinyurl_icon.parentNode.removeChild(copy_tinyurl_icon);
        }
    }
};
var winUtils = require("window-utils");
var tracker = new winUtils.WindowTracker(copy_tinyurl);
Comment 1 Sebastian H. [:aryx][:archaeopteryx] 2012-02-09 02:46:20 PST
Created attachment 595693 [details]
about:memory?verbose content with cuddlefish.js leak
Comment 2 Dave Townsend [:mossop] 2012-02-09 11:30:01 PST
Alex, is this the same as bug 724433, or fixed by your patch there?
Comment 3 Nicholas Nethercote [:njn] 2012-02-14 11:53:14 PST
Bug 726485 sounds rather similar, and it wasn't fixed by bug 724433, IIUC.
Comment 4 Alexandre Poirot [:ochameau] PTO, back on 1st 2012-02-14 13:58:10 PST
I think that you shouldn't be leaking with bug 724433 being fixed,
if you remove const tabs = require("tabs"); and stop using this API.
`tabs` requires `windows` which is leaking.

Otherwise, it should be completely fixed though bug 724404.
Comment 5 Thomasy 2012-02-15 18:24:44 PST
It is fixed by bug 724433 and  bug 724404.

Note You need to log in before you can comment on or make changes to this bug.