Bug 1139460 - Part 1 - Avoid Telemetry payload data changes after collection. r=vladan
☠☠ backed out by 6901a267f856 ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 18 Mar 2015 12:35:49 +0100
changeset 237233 58c2eb92a95925e54633afd7299aa6cd4209a197
parent 237232 46e43ff8cdb50b3c52d4e6353dc8b02016944d48
child 237234 ea6da072eb0cbabda48f5c5cee06bd411877efb1
push id57898
push usercbook@mozilla.com
push dateThu, 02 Apr 2015 12:14:17 +0000
treeherdermozilla-inbound@63c87250946e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvladan
bugs1139460
milestone40.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,