[llvm] 1d13c5e - Revert (and fix properly) "Uninitialize the file descriptor."

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 17:44:57 PST 2023


Author: Mircea Trofin
Date: 2023-02-01T17:44:47-08:00
New Revision: 1d13c5ec47664ab123f0cf02b349a271e5b446ab

URL: https://github.com/llvm/llvm-project/commit/1d13c5ec47664ab123f0cf02b349a271e5b446ab
DIFF: https://github.com/llvm/llvm-project/commit/1d13c5ec47664ab123f0cf02b349a271e5b446ab.diff

LOG: Revert (and fix properly) "Uninitialize the file descriptor."

This reverts commit f514b0e144db063931d19a8ebc2dc42083d0eb2f.

The culprit is that InEC is initialized before Inbound, and Inbound's
initialization happens through a call to openFileForRead. However, the
typical initialization order warnings don't fire; so the behavior was:
Inbound is initialized correctly by openFileForRead; then it's reset to
whatever initializer value (0 originally).

A fix is to move Inbound's decl upfront. I'd still prefer initializing
it to something - and -1 seems like a more appropriate value (it causes
a fail-fast rather than a hang due to trying to read from a
valid-looking but unopen fd).

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/InteractiveModelRunner.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/InteractiveModelRunner.h b/llvm/include/llvm/Analysis/InteractiveModelRunner.h
index 16fc0982ce5e..a35e06df09a1 100644
--- a/llvm/include/llvm/Analysis/InteractiveModelRunner.h
+++ b/llvm/include/llvm/Analysis/InteractiveModelRunner.h
@@ -57,11 +57,13 @@ class InteractiveModelRunner : public MLModelRunner {
 
 private:
   void *evaluateUntyped() override;
+  // This must be declared before InEC if we want to initialize it in the
+  // ctor initializer list.
+  int Inbound = -1;
   const std::vector<TensorSpec> InputSpecs;
   const TensorSpec OutputSpec;
   std::error_code OutEC;
   std::error_code InEC;
-  int Inbound;
   std::vector<char> OutputBuffer;
   std::unique_ptr<Logger> Log;
 };


        


More information about the llvm-commits mailing list