Bug 1139460 - Part 1 - Avoid Telemetry payload data changes after collection. r=vladan
☠☠ backed out by ae8e6c0aea7e ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 18 Mar 2015 12:35:49 +0100
changeset 265043 02623719b09419865790bcf5dad10f253509372f
parent 265042 cb309087f978fc39dacf1e5ff565fd4c84d7dd95
child 265044 20d390554f5e9c42e598455f3c151a02183041fc
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [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,