Bug 1555798 - Test that registering and recording dynamic events and scalars together does not crash. r=Dexter
authorChris H-C <chutten@mozilla.com>
Fri, 31 May 2019 15:01:23 +0000
changeset 476414 551589932a0aa36d4d872645f75d0d65bb770797
parent 476413 e4c9890a1f35d421b9f7a42b064d3d8df1a8c152
child 476415 239b2e23497f7cb3f77b1d06ee14f07c973de793
push id36094
push useraiakab@mozilla.com
push dateFri, 31 May 2019 21:48:40 +0000
treeherdermozilla-central@a73077366144 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter
bugs1555798
milestone69.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 1555798 - Test that registering and recording dynamic events and scalars together does not crash. r=Dexter Depends on D33274 Differential Revision: https://phabricator.services.mozilla.com/D33275
toolkit/components/telemetry/tests/unit/test_bug1555798.js
toolkit/components/telemetry/tests/unit/xpcshell.ini
new file mode 100644
--- /dev/null
+++ b/toolkit/components/telemetry/tests/unit/test_bug1555798.js
@@ -0,0 +1,47 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/
+*/
+
+ChromeUtils.defineModuleGetter(this, "TelemetryTestUtils",
+                             "resource://testing-common/TelemetryTestUtils.jsm");
+
+add_task(async function test_bug1555798() {
+  /*
+  The idea behind this bug is that the registration of dynamic scalars causes
+  the position of the scalarinfo for telemetry.dynamic_events_count to move
+  which causes things to asplode.
+
+  So to test this we'll be registering two dynamic events, recording to one of
+  the events (to ensure the Scalar for event1 is allocated from the unmoved
+  DynamicScalarInfo&), registering several dynamic scalars to cause the
+  nsTArray of DynamicScalarInfo to realloc, and then recording to the second
+  event to make the Event Summary Scalar for event2 try to allocate from where
+  the DynamicScalarInfo used to be.
+  */
+  Telemetry.clearEvents();
+
+  const DYNAMIC_CATEGORY = "telemetry.test.dynamic.event";
+  Telemetry.registerEvents(DYNAMIC_CATEGORY, {
+    "an_event": {
+      methods: ["a_method"],
+      objects: ["an_object", "another_object"],
+      record_on_release: true,
+      expired: false,
+    },
+  });
+  Telemetry.recordEvent(DYNAMIC_CATEGORY, "a_method", "an_object");
+
+  for (let i = 0; i < 100; ++i) {
+    Telemetry.registerScalars("telemetry.test.dynamic" + i, {
+      "scalar_name": {
+        kind: Ci.nsITelemetry.SCALAR_TYPE_COUNT,
+        record_on_release: true,
+      },
+    });
+    Telemetry.scalarAdd("telemetry.test.dynamic" + i + ".scalar_name", 1);
+  }
+
+  Telemetry.recordEvent(DYNAMIC_CATEGORY, "a_method", "another_object");
+
+  TelemetryTestUtils.assertNumberOfEvents(2, {}, {process: "dynamic"});
+});
--- a/toolkit/components/telemetry/tests/unit/xpcshell.ini
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.ini
@@ -98,8 +98,9 @@ skip-if = (os == "android") || (os == "l
 run-if = nightly_build && (os == 'win')
 [test_EcosystemTelemetry.js]
 skip-if = (os == "linux" && bits == 32) # lack of support on test runners (see bug 1310703, comment78)
 [test_EventPing.js]
 [test_EventPing_disabled.js]
 tags = coverage
 [test_CoveragePing.js]
 [test_PrioPing.js]
+[test_bug1555798.js]