Various tests leak windows when run by themselves due to async PlacesTransactions being passed arrays

RESOLVED FIXED in Firefox 57

Status

()

Toolkit
Places
P1
normal
RESOLVED FIXED
9 months ago
9 months ago

People

(Reporter: standard8, Assigned: standard8)

Tracking

Trunk
mozilla57
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox57 fixed)

Details

(Whiteboard: [fxsearch])

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Assignee)

Description

9 months ago
bookmarkProperties.js & other places pass arrays to PlacesTransactions, which then stores them for a period of time.

This can cause tests to leak when run by themselves:

51 ERROR TEST-UNEXPECTED-FAIL | browser/components/places/tests/browser/browser_addBookmarkForFrame.js | leaked 1 window(s) until shutdown [url = about:blank]
52 ERROR TEST-UNEXPECTED-FAIL | browser/components/places/tests/browser/browser_addBookmarkForFrame.js | leaked 1 window(s) until shutdown [url = chrome://browser/content/places/bookmarkProperties2.xul]

To fix this, Marco put me onto the fact that we need to clone Arrays into a different global scope, this then fixes the issues.
Comment hidden (mozreview-request)
(Assignee)

Updated

9 months ago
Blocks: 1391393
(Assignee)

Updated

9 months ago
Status: NEW → ASSIGNED

Comment 2

9 months ago
mozreview-review
Comment on attachment 8903727 [details]
Bug 1395994 - Clone arrays to fix a leak of windows caused by PlacesTransactions keeping references to arrays passed to it.

https://reviewboard.mozilla.org/r/175486/#review181016

::: toolkit/components/places/PlacesTransactions.jsm:808
(Diff revision 1)
>  
>        if (!Array.isArray(aValue))
>          throw new Error(`${name} input property value must be an array`);
>  
> -      // This also takes care of abandoning the global scope of the input
> -      // array (through Array.prototype).
> +      // We must create a new array in the local scope to keep the memory
> +      // allocators happy. We can't use Cu.cloneInto as that doesn't handle

I'd probably s/to keep the memory allocators happy/to avoid a memory leak due to the array global object./

::: toolkit/components/places/PlacesTransactions.jsm:813
(Diff revision 1)
> -      // array (through Array.prototype).
> -      return aValue.map(baseProp.validateValue);
> +      // allocators happy. We can't use Cu.cloneInto as that doesn't handle
> +      // the URIs. Slice & map also aren't good enough, so we start off with
> +      // a clean array and insert what we need into it.
> +      let newArray = [];
> +
> +      for (let item of aValue) {

nit: remove empty newline
Attachment #8903727 - Flags: review?(mak77) → review+
Comment hidden (mozreview-request)

Comment 4

9 months ago
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c0d3dbb49f68
Clone arrays to fix a leak of windows caused by PlacesTransactions keeping references to arrays passed to it. r=mak
https://hg.mozilla.org/mozilla-central/rev/c0d3dbb49f68
Status: ASSIGNED → RESOLVED
Last Resolved: 9 months ago
status-firefox57: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.