[compiler-rt] r244546 - [sanitizers] Use portable file read/write wrappers on process pipes

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 17:30:22 PDT 2015


Author: rnk
Date: Mon Aug 10 19:30:22 2015
New Revision: 244546

URL: http://llvm.org/viewvc/llvm-project?rev=244546&view=rev
Log:
[sanitizers] Use portable file read/write wrappers on process pipes

This fixes a minor error checking bug around calling
internal_read/write, and makes the code more portable for D11791.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_internal.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_internal.h?rev=244546&r1=244545&r2=244546&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_internal.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_internal.h Mon Aug 10 19:30:22 2015
@@ -90,8 +90,8 @@ class SymbolizerProcess {
   }
 
   const char *path_;
-  int input_fd_;
-  int output_fd_;
+  fd_t input_fd_;
+  fd_t output_fd_;
 
   static const uptr kBufferSize = 16 * 1024;
   char buffer_[kBufferSize];

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc?rev=244546&r1=244545&r2=244546&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_process_libcdep.cc Mon Aug 10 19:30:22 2015
@@ -55,9 +55,9 @@ const char *SymbolizerProcess::SendComma
 
 bool SymbolizerProcess::Restart() {
   if (input_fd_ != kInvalidFd)
-    internal_close(input_fd_);
+    CloseFile(input_fd_);
   if (output_fd_ != kInvalidFd)
-    internal_close(output_fd_);
+    CloseFile(output_fd_);
   return StartSymbolizerSubprocess();
 }
 
@@ -76,11 +76,12 @@ bool SymbolizerProcess::ReadFromSymboliz
     return true;
   uptr read_len = 0;
   while (true) {
-    uptr just_read = internal_read(input_fd_, buffer + read_len,
-                                   max_length - read_len - 1);
+    uptr just_read = 0;
+    bool success = ReadFromFile(input_fd_, buffer + read_len,
+                                max_length - read_len - 1, &just_read);
     // We can't read 0 bytes, as we don't expect external symbolizer to close
     // its stdout.
-    if (just_read == 0 || just_read == (uptr)-1) {
+    if (!success || just_read == 0) {
       Report("WARNING: Can't read from symbolizer at fd %d\n", input_fd_);
       return false;
     }
@@ -95,8 +96,9 @@ bool SymbolizerProcess::ReadFromSymboliz
 bool SymbolizerProcess::WriteToSymbolizer(const char *buffer, uptr length) {
   if (length == 0)
     return true;
-  uptr write_len = internal_write(output_fd_, buffer, length);
-  if (write_len == 0 || write_len == (uptr)-1) {
+  uptr write_len = 0;
+  bool success = WriteToFile(output_fd_, buffer, length, &write_len);
+  if (!success || write_len != length) {
     Report("WARNING: Can't write to symbolizer at fd %d\n", output_fd_);
     return false;
   }




More information about the llvm-commits mailing list