summaryrefslogtreecommitdiff
path: root/bolt/runtime
diff options
context:
space:
mode:
authorMarius Wachtler <undingen@gmail.com>2021-11-05 16:47:30 +0100
committerMaksim Panchenko <maks@fb.com>2021-11-05 16:47:30 +0100
commit3b00a3a2f8072e312736e15c6bb077d507139529 (patch)
treec67e2b1d57914c594d33ccacdcfc6e6acd2b0e10 /bolt/runtime
parentae585be11cfac7bccbb7bb463e44a3d95e477cbd (diff)
downloadllvm-3b00a3a2f8072e312736e15c6bb077d507139529.tar.gz
[PR] instr: change assert to allow FD 0 return by __open()
Summary: In some cases __open() is returning 0 for me. The open syscall will return a negative number (-1) on error so 0 should be valid. This happens when one compiles a BOLT instrumented executable of pyston (python implementation) and afterwards pip installs a package which needs to be compiled and sets CFLAGS=-pipe. I could not reduce it down to a small testcase but I guess it one can trigger when manually closing std{in, out, err}. Everything seems to work normally when disabling the assert for 0 in getBinaryPath() - I decided to also modify the second case in readDescriptions() even though I did not run into that one yet. (cherry picked from FBD32409548)
Diffstat (limited to 'bolt/runtime')
-rw-r--r--bolt/runtime/instr.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp
index f6c9916037c0..86fb772b15c2 100644
--- a/bolt/runtime/instr.cpp
+++ b/bolt/runtime/instr.cpp
@@ -626,7 +626,7 @@ static char *getBinaryPath() {
uint64_t FDdir = __open(DirPath,
/*flags=*/0 /*O_RDONLY*/,
/*mode=*/0666);
- assert(static_cast<int64_t>(FDdir) > 0,
+ assert(static_cast<int64_t>(FDdir) >= 0,
"failed to open /proc/self/map_files");
while (long Nread = __getdents(FDdir, (struct dirent *)Buf, BufSize)) {
@@ -662,7 +662,7 @@ ProfileWriterContext readDescriptions() {
uint64_t FD = __open(BinPath,
/*flags=*/0 /*O_RDONLY*/,
/*mode=*/0666);
- assert(static_cast<int64_t>(FD) > 0, "failed to open binary path");
+ assert(static_cast<int64_t>(FD) >= 0, "failed to open binary path");
Result.FileDesc = FD;