From f4b88af71e5bea2205d6a666d77f2a3611c21564 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 18 Jan 2026 14:36:51 -0800 Subject: [PATCH] JitRegister: Check Open return code If the call to `Open` a perf map fails don't set `s_is_enabled` (though it could already be true if you're also using VTUNE) and don't call `std::setvbuf` with a null stream. Also fix a typo in a comment (`if` -> `in`) --- Source/Core/Common/JitRegister.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index 8555ca8073..4d8ba45fc6 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -42,11 +42,13 @@ void Init(const std::string& perf_dir) { const std::string dir = perf_dir.empty() ? "/tmp" : perf_dir; const std::string filename = fmt::format("{}/perf-{}.map", dir, getpid()); - s_perf_map_file.Open(filename, "w"); - // Disable buffering in order to avoid missing some mappings - // if the event of a crash: - std::setvbuf(s_perf_map_file.GetHandle(), nullptr, _IONBF, 0); - s_is_enabled = true; + if (s_perf_map_file.Open(filename, "w")) + { + // Disable buffering in order to avoid missing some mappings + // in the event of a crash: + std::setvbuf(s_perf_map_file.GetHandle(), nullptr, _IONBF, 0); + s_is_enabled = true; + } } }