Bug 1139460 - Part 1 - Avoid Telemetry payload data changes after collection. r=vladan
☠☠ backed out by a18c01416b7f ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 18 Mar 2015 12:35:49 +0100
changeset 265724 0994ae599f13a81f5159d620e09a142de0d6a4f0
parent 265723 b192e6e16c1bcd6add690997d89fb4c753281a69
child 265725 a139d273f07b881f0be4499d806792fc8ed7387f
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs1139460
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1139460 - Part 1 - Avoid Telemetry payload data changes after collection. r=vladan
toolkit/components/telemetry/TelemetryPing.jsm
--- a/toolkit/components/telemetry/TelemetryPing.jsm
+++ b/toolkit/components/telemetry/TelemetryPing.jsm
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
+const myScope = this;
 
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://gre/modules/debug.js", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 Cu.import("resource://gre/modules/osfile.jsm", this);
 Cu.import("resource://gre/modules/Promise.jsm", this);
 Cu.import("resource://gre/modules/DeferredTask.jsm", this);
@@ -312,16 +313,21 @@ let Impl = {
    *                  environment data.
    *
    * @returns Promise<Object> A promise that resolves when the ping is completely assembled.
    */
   assemblePing: function assemblePing(aType, aPayload, aOptions = {}) {
     this._log.trace("assemblePing - Type " + aType + ", Server " + this._server +
                     ", aOptions " + JSON.stringify(aOptions));
 
+    // Clone the payload data so we don't race against unexpected changes in subobjects that are
+    // still referenced by other code.
+    // We can't trust all callers to do this properly on their own.
+    let payload = Cu.cloneInto(aPayload, myScope);
+
     // Fill the common ping fields.
     let pingData = {
       type: aType,
       id: generateUUID(),
       creationDate: (new Date()).toISOString(),
       version: PING_FORMAT_VERSION,
       application: this._getApplicationSection(),
       payload: aPayload,