Skip to content

Commit 09fd26c

Browse files
committed
Copilot review fixes.
1 parent ade8f3c commit 09fd26c

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

Extension/src/LanguageServer/extension.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,22 @@ function containsFilteredTelemetryData(str: string): boolean {
12891289
return regex.test(str);
12901290
}
12911291

1292+
// Non-null fault addresses are randomized by ASLR (and use-after-free/wild pointers vary run to
1293+
// run), so embedding the raw value in CrashingThreadCallStack would fragment crash buckets and
1294+
// make CrashCount meaningless. Preserve near-null addresses (typical null-pointer dereferences,
1295+
// which are stable and useful for bucketing), but replace arbitrary addresses with a stable
1296+
// placeholder so identical crashes still de-duplicate.
1297+
function bucketSignalAddress(address: string): string {
1298+
let value: bigint;
1299+
try {
1300+
value = BigInt(address.trim());
1301+
} catch {
1302+
return address; // Not a parseable address; leave it untouched.
1303+
}
1304+
// 0x10000 (64 KB) covers null plus small member/array offsets off a null pointer.
1305+
return value < 0x10000n ? address : "<non-null>";
1306+
}
1307+
12921308
async function handleCrashFileRead(crashDirectory: string, crashFile: string, crashDate: Date, err: NodeJS.ErrnoException | undefined | null, data: string): Promise<void> {
12931309
if (err) {
12941310
if (err.code === "ENOENT") {
@@ -1329,7 +1345,7 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
13291345
}
13301346
if (lines[crashStackStartLine].startsWith("SIG")) {
13311347
signalType = `${lines[crashStackStartLine]}\n`;
1332-
signalInfo = `si_code=${lines[crashStackStartLine + 1]}, si_addr=${lines[crashStackStartLine + 2]}\n`;
1348+
signalInfo = `si_code=${lines[crashStackStartLine + 1]}, si_addr=${bucketSignalAddress(lines[crashStackStartLine + 2])}\n`;
13331349
crashStackStartLine += 3;
13341350
} else {
13351351
// The signal type may fail to be written.
@@ -1391,17 +1407,6 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr
13911407
// Compute pendingOffset.
13921408
if (isMac) {
13931409
pendingOffset += line.substring(offsetPos2);
1394-
const startAddressPos: number = line.indexOf("0x");
1395-
if (startAddressPos === -1 || startAddressPos >= startPos) {
1396-
// unexpected
1397-
pendingOffset += " <Missing 0x>";
1398-
} else {
1399-
let pendingAddressData: string = line.substring(startAddressPos, startPos).trimEnd();
1400-
if (containsFilteredTelemetryData(pendingAddressData)) {
1401-
pendingAddressData = "?";
1402-
}
1403-
pendingOffset += " " + pendingAddressData;
1404-
}
14051410
} else {
14061411
const endPos: number = line.indexOf(">", offsetPos2);
14071412
if (endPos === -1) {

0 commit comments

Comments
 (0)