[llvm] [BOLT] close map_files FD (PR #156489)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 09:42:54 PDT 2025


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/156489

The BOLT runtime currently does not close the FD pointing to /proc/self/map_files. This does not actually hurt anything but was at least a bit of a red herring for me when looking through strace on a BOLT instrumented binary.

>From 57663aa46040f2543741b1fd57cb701ac9fbb9ca Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Tue, 2 Sep 2025 16:41:36 +0000
Subject: [PATCH] [BOLT] close map_files FD

The BOLT runtime currently does not close the FD pointing to
/proc/self/map_files. This does not actually hurt anything but was at
least a bit of a red herring for me when looking through strace on a
BOLT instrumented binary.
---
 bolt/runtime/instr.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp
index a42750cef6b6e..1f54a500dbf98 100644
--- a/bolt/runtime/instr.cpp
+++ b/bolt/runtime/instr.cpp
@@ -714,9 +714,11 @@ static char *getBinaryPath() {
       uint32_t Ret = __readlink(FindBuf, TargetPath, sizeof(TargetPath));
       assert(Ret != -1 && Ret != BufSize, "readlink error");
       TargetPath[Ret] = '\0';
+      __close(FDdir);
       return TargetPath;
     }
   }
+  __close(FDdir);
   return nullptr;
 }
 



More information about the llvm-commits mailing list