Skip to content

Commit a293131

Browse files
committed
Fix bucketing of addresses that can change. Fix the process name logging.
1 parent 09fd26c commit a293131

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

Extension/src/LanguageServer/extension.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,23 @@ function bucketSignalAddress(address: string): string {
13051305
return value < 0x10000n ? address : "<non-null>";
13061306
}
13071307

1308+
// An unsymbolized frame is reported as a raw runtime address. Addresses in the fixed-base main
1309+
// executable (non-PIE on Linux) stay constant across runs and are useful for bucketing, but
1310+
// addresses in the ASLR-randomized shared-library/mmap region (Linux 0x7f..., and on macOS the
1311+
// PIE main image and dyld shared cache) shift every launch and would fragment crash buckets. Keep
1312+
// the low, fixed addresses but replace high (relocated) ones with a stable placeholder. 4 GB is a
1313+
// safe cut: a non-PIE executable's own code loads well below it, while the relocated region is far
1314+
// above it.
1315+
function bucketFrameAddress(address: string): string {
1316+
let value: bigint;
1317+
try {
1318+
value = BigInt(address.trim());
1319+
} catch {
1320+
return address; // Not a parseable address; leave it untouched.
1321+
}
1322+
return value < 0x100000000n ? address : "<relocated>";
1323+
}
1324+
13081325
async function handleCrashFileRead(crashDirectory: string, crashFile: string, crashDate: Date, err: NodeJS.ErrnoException | undefined | null, data: string): Promise<void> {
13091326
if (err) {
13101327
if (err.code === "ENOENT") {
@@ -1317,7 +1334,7 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
13171334
let signalInfo: string;
13181335
const isCppToolsSrv2: boolean = crashFile.startsWith("cpptools-srv2");
13191336
const isCppToolsSrv: boolean = crashFile.startsWith("cpptools-srv");
1320-
const telemetryHeader: string = (isCppToolsSrv2 ? "cpptools-srv2 process" : isCppToolsSrv ? "cpptools-srv process" : "cpptools process") + "\n";
1337+
const processName: string = (isCppToolsSrv2 ? "cpptools-srv2 process" : isCppToolsSrv ? "cpptools-srv process" : "cpptools process") + "\n";
13211338
const filtPath: string | null = which.sync("c++filt", { nothrow: true });
13221339
const isMac: boolean = process.platform === "darwin";
13231340
const startStr: string = isMac ? " _" : "<";
@@ -1354,7 +1371,7 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
13541371
signalType = "SIGMISSING\n";
13551372
signalInfo = "";
13561373
}
1357-
data = telemetryHeader + signalType + signalInfo;
1374+
data = processName + signalType + signalInfo;
13581375
let crashCallStack: string = "";
13591376
let validFrameFound: boolean = false;
13601377
for (let lineNum: number = crashStackStartLine; lineNum < lines.length - 3; ++lineNum) { // skip last lines
@@ -1367,7 +1384,7 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
13671384
if (startAddressPos === -1 || endAddressPos === -1 || startAddressPos >= endAddressPos) {
13681385
pendingCallStack = "Unexpected offset\n";
13691386
} else {
1370-
let pendingAddressData: string = line.substring(startAddressPos, endAddressPos) + "\n";
1387+
let pendingAddressData: string = bucketFrameAddress(line.substring(startAddressPos, endAddressPos)) + "\n";
13711388
if (containsFilteredTelemetryData(pendingAddressData)) {
13721389
pendingAddressData = "?\n";
13731390
}
@@ -1448,7 +1465,7 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
14481465
prevCppCrashCallStackData = crashCallStack;
14491466

14501467
if (lines.length >= 6 && util.getLoggingLevel() >= 1) {
1451-
getCrashCallStacksChannel().appendLine(`\n${isCppToolsSrv2 ? "cpptools-srv2" : isCppToolsSrv ? "cpptools-srv" : "cpptools"}\n${crashDate.toLocaleString()}\n${signalType}${signalInfo}${crashCallStack}${crashLog.length > 0 ? "\n\n" + crashLog : ""}`);
1468+
getCrashCallStacksChannel().appendLine(`\n${processName}${crashDate.toLocaleString()}\n${signalType}${signalInfo}${crashCallStack}${crashLog.length > 0 ? "\n\n" + crashLog : ""}`);
14521469
}
14531470
}
14541471

0 commit comments

Comments
 (0)