Bug 1246555 - Abort infinite loop when a marker has a recursive stack trace in the marker details view. r=vp

MozReview-Commit-ID: KLBXHfNF7EB
This commit is contained in:
Jordan Santell 2016-02-23 14:13:56 -08:00
Родитель 13aa4cf354
Коммит f0d5fddf79
2 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -212,8 +212,17 @@ const DOM = {
container.className = "marker-details-stack";
container.appendChild(labelName);
// Workaround for profiles that have looping stack traces. See
// bug 1246555.
let wasAsyncParent = false;
let seen = new Set();
while (frameIndex > 0) {
if (seen.has(frameIndex)) {
break;
}
seen.add(frameIndex);
let frame = frames[frameIndex];
let url = frame.source;
let displayName = frame.functionDisplayName;

Просмотреть файл

@ -58,9 +58,21 @@ function* spawnTest() {
return m.start;
}, 0);
// Override the timestamp marker's stack with our own recursive stack, which
// can happen for unknown reasons (bug 1246555); we should not cause a crash
// when attempting to render a recursive stack trace
let timestampMarker = markers.find(m => m.name === "ConsoleTime");
ok(typeof timestampMarker.stack === "number", "ConsoleTime marker has a stack before overwriting.");
let frames = PerformanceController.getCurrentRecording().getFrames();
let frameIndex = timestampMarker.stack = frames.length;
frames.push({ line: 1, column: 1, source: "file.js", functionDisplayName: "test", parent: frameIndex + 1});
frames.push({ line: 1, column: 1, source: "file.js", functionDisplayName: "test", parent: frameIndex + 2 });
frames.push({ line: 1, column: 1, source: "file.js", functionDisplayName: "test", parent: frameIndex });
const tests = {
ConsoleTime: function (marker) {
info("Got `ConsoleTime` marker with data: " + JSON.stringify(marker));
ok(marker.stack === frameIndex, "Should have the ConsoleTime marker with recursive stack");
shouldHaveStack($, "startStack", marker);
shouldHaveStack($, "endStack", marker);
shouldHaveLabel($, "Timer Name:", "!!!", marker);