{"record":{"id":"5152b69175e7c59d","repo":"dotnet/runtime","slug":"warning-logger-logvprintf-failed-to-flush-log","errorCode":null,"errorMessage":"WARNING: [Logger::LogVprintf] Failed to flush log file. GetLastError()=%u\\n","messagePattern":"WARNING: \\[Logger::LogVprintf\\] Failed to flush log file\\. GetLastError\\(\\)=%u\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/coreclr/tools/superpmi/superpmi-shared/logging.cpp","lineNumber":294,"sourceCode":"        const char* timeStr = \"\";\n#endif // TARGET_UNIX\n\n        const char logEntryFmtStr[] = \"%s - %s [%s:%d] - %s - %s\\r\\n\";\n        size_t logEntryBuffSize = sizeof(logEntryFmtStr) + strlen(timeStr) + strlen(function) + strlen(file) + /* line number */ 10 +\n                                  strlen(logLevelStr) + strlen(fullMsg);\n\n        char* logEntry = new char[logEntryBuffSize];\n        sprintf_s(logEntry, logEntryBuffSize, logEntryFmtStr, timeStr, function, file, line, logLevelStr, fullMsg);\n        size_t logEntryLen = strlen(logEntry);\n\n        DWORD bytesWritten;\n\n        if (!WriteFile(s_logFile, logEntry, (DWORD)logEntryLen, &bytesWritten, nullptr))\n            fprintf(stderr, \"WARNING: [Logger::LogVprintf] Failed to write to log file. GetLastError()=%u\\n\",\n                    GetLastError());\n\n        if (!FlushFileBuffers(s_logFile))\n            fprintf(stderr, \"WARNING: [Logger::LogVprintf] Failed to flush log file. GetLastError()=%u\\n\",\n                    GetLastError());\n\n        delete[] logEntry;\n\n#ifndef TARGET_UNIX\n        free((void*)timeStr);\n#endif // !TARGET_UNIX\n    }\n\n#ifndef TARGET_UNIX\nCleanUp:\n#endif // !TARGET_UNIX\n\n    minipal_mutex_leave(&s_critSec);\n    delete[] fullMsg;\n}\n\n//","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/coreclr/tools/superpmi/superpmi-shared/logging.cpp#L276-L312","documentation":"In SuperPMI's shared Logger::LogVprintf, after a log line is written with WriteFile the logger calls FlushFileBuffers(s_logFile) to force it to disk. If the flush fails the logger only emits this WARNING with GetLastError() and continues; logging is best-effort and never throws. It signals that subsequent log lines may be buffered or lost.","triggerScenarios":"The SuperPMI log file lives on a volume that fails FlushFileBuffers: disk full/quota hit, removable/network drive disconnected, file truncated/deleted underneath the handle, or the handle became invalid after an I/O error. Windows reports the reason via GetLastError.","commonSituations":"Logging to a network share that dropped; /tmp filled by a large .mch method-context file while SuperPMIShimLogPath points at the same volume; antivirus/backup locking the log handle; running on a CI agent whose workspace is cleaned mid-run.","solutions":["Point SuperPMIShimLogPath at a local disk with ample free space.","Free disk space / raise quota on the log volume and restart the SuperPMI run.","Disable or move antivirus/backup that locks the log file during the run.","If warnings are non-fatal, ignore them but re-run on a healthy disk to get complete logs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before a SuperPMI run, check the log path is healthy.\n#include <sys/statvfs.h>\nstatic bool LogPathHealthy(const char* dir) {\n    struct statvfs s;\n    if (statvfs(dir, &s) != 0) return false;\n    unsigned long freeMb = (s.f_bavail * (s.f_frsize ?: 1)) >> 20;\n    return freeMb > 100; // require >100MB free\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point SuperPMIShimLogPath at a local disk with generous free space.","Monitor disk usage during long SuperPMI runs; .mch files grow large.","Exclude the log directory from AV/backup scans that lock handles.","Treat the WARNING as non-fatal but re-run on a healthy disk for complete logs."],"tags":["superpmi","logging","flushfilebuffers","disk-full","windows","io"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}