From 3915ef03e3c37657715d9330bb7fb7b04dfd54ab Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 2 Sep 2026 13:00:07 -0700 Subject: [PATCH 1/3] Ignore empty crash report files --- Extension/src/LanguageServer/extension.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 7b20221cf..6f98d5942 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -48,7 +48,7 @@ export const CppSourceStr: string = "C/C++"; export const configPrefix: string = "C/C++: "; let prevMacCrashFile: string; -let prevCppCrashFile: string; +const pendingCppCrashFiles: Set = new Set(); let prevCppCrashCallStackData: string = ""; export let clients: ClientCollection; let activeDocument: vscode.TextDocument | undefined; @@ -1115,7 +1115,7 @@ export function usesCrashHandler(): boolean { export function watchForCrashes(crashDirectory: string): void { if (crashDirectory !== "") { - prevCppCrashFile = ""; + pendingCppCrashFiles.clear(); fs.stat(crashDirectory, (err) => { const crashObject: Record = {}; if (err?.code) { @@ -1131,19 +1131,20 @@ export function watchForCrashes(crashDirectory: string): void { if (event !== "change") { return; } - if (!filename || filename === prevCppCrashFile) { + if (!filename || pendingCppCrashFiles.has(filename)) { return; } - prevCppCrashFile = filename; if (!filename.startsWith("cpptools")) { return; } + pendingCppCrashFiles.add(filename); const crashDate: Date = new Date(); isWritingCrashCallStack = true; // Wait 5 seconds to allow time for the crash log to finish being written. setTimeout(() => { isWritingCrashCallStack = false; + pendingCppCrashFiles.delete(filename); fs.readFile(path.resolve(crashDirectory, filename), 'utf8', (err, data) => { void handleCrashFileRead(crashDirectory, filename, crashDate, err, data); }); @@ -1323,6 +1324,9 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, cr } return logCppCrashTelemetry("readFile: " + err.code); } + if (data.length === 0) { + return; + } const lines: string[] = data.split("\n"); let signalInfo: string; From c177f6d0653af5c43bd456114c3839fd9291501b Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 2 Sep 2026 15:41:09 -0700 Subject: [PATCH 2/3] Preserve pending crash reads across clients --- Extension/src/LanguageServer/extension.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index 6f98d5942..c8a5c4994 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -48,7 +48,7 @@ export const CppSourceStr: string = "C/C++"; export const configPrefix: string = "C/C++: "; let prevMacCrashFile: string; -const pendingCppCrashFiles: Set = new Set(); +const pendingCppCrashPaths: Set = new Set(); let prevCppCrashCallStackData: string = ""; export let clients: ClientCollection; let activeDocument: vscode.TextDocument | undefined; @@ -1115,7 +1115,6 @@ export function usesCrashHandler(): boolean { export function watchForCrashes(crashDirectory: string): void { if (crashDirectory !== "") { - pendingCppCrashFiles.clear(); fs.stat(crashDirectory, (err) => { const crashObject: Record = {}; if (err?.code) { @@ -1131,21 +1130,22 @@ export function watchForCrashes(crashDirectory: string): void { if (event !== "change") { return; } - if (!filename || pendingCppCrashFiles.has(filename)) { + if (!filename || !filename.startsWith("cpptools")) { return; } - if (!filename.startsWith("cpptools")) { + const crashPath: string = path.resolve(crashDirectory, filename); + if (pendingCppCrashPaths.has(crashPath)) { return; } - pendingCppCrashFiles.add(filename); + pendingCppCrashPaths.add(crashPath); const crashDate: Date = new Date(); isWritingCrashCallStack = true; // Wait 5 seconds to allow time for the crash log to finish being written. setTimeout(() => { isWritingCrashCallStack = false; - pendingCppCrashFiles.delete(filename); - fs.readFile(path.resolve(crashDirectory, filename), 'utf8', (err, data) => { + pendingCppCrashPaths.delete(crashPath); + fs.readFile(crashPath, 'utf8', (err, data) => { void handleCrashFileRead(crashDirectory, filename, crashDate, err, data); }); }, 5000); From 5c3f43e64ce56490bd95686077297dd4d03c0ea4 Mon Sep 17 00:00:00 2001 From: Sean McManus Date: Wed, 2 Sep 2026 19:31:52 -0700 Subject: [PATCH 3/3] Keep crash writing state for pending reports --- Extension/src/LanguageServer/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/src/LanguageServer/extension.ts b/Extension/src/LanguageServer/extension.ts index c8a5c4994..67a7d1720 100644 --- a/Extension/src/LanguageServer/extension.ts +++ b/Extension/src/LanguageServer/extension.ts @@ -1143,8 +1143,8 @@ export function watchForCrashes(crashDirectory: string): void { // Wait 5 seconds to allow time for the crash log to finish being written. setTimeout(() => { - isWritingCrashCallStack = false; pendingCppCrashPaths.delete(crashPath); + isWritingCrashCallStack = pendingCppCrashPaths.size > 0; fs.readFile(crashPath, 'utf8', (err, data) => { void handleCrashFileRead(crashDirectory, filename, crashDate, err, data); });