Fix GCC and clang debug builds.

Change-Id: I5ad94dd6cc643a5b98eae09f8b0c09481710c8f2
diff --git a/include/perfetto/base/scoped_file.h b/include/perfetto/base/scoped_file.h
index 17c5e03..7e380f0 100644
--- a/include/perfetto/base/scoped_file.h
+++ b/include/perfetto/base/scoped_file.h
@@ -79,12 +79,15 @@
 };
 
 using ScopedFile = ScopedResource<int, close, -1>;
-inline static ScopedFile OpenFile(const std::string& path, int flags) {
+inline static ScopedFile OpenFile(const std::string& path,
+                                  int flags,
+                                  mode_t mode = 0) {
+  PERFETTO_DCHECK((flags & O_CREAT) == 0 || mode != 0);
 #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
-  ScopedFile fd(open(path.c_str(), flags));
+  ScopedFile fd(open(path.c_str(), flags, mode));
 #else
   // Always open a ScopedFile with O_CLOEXEC so we can safely fork and exec.
-  ScopedFile fd(open(path.c_str(), flags | O_CLOEXEC));
+  ScopedFile fd(open(path.c_str(), flags | O_CLOEXEC, mode));
 #endif
   return fd;
 }
diff --git a/src/profiling/memory/socket_listener.cc b/src/profiling/memory/socket_listener.cc
index b606d47..ea5780f 100644
--- a/src/profiling/memory/socket_listener.cc
+++ b/src/profiling/memory/socket_listener.cc
@@ -53,7 +53,8 @@
       InitProcess(&entry, self->peer_pid(), std::move(fds[0]),
                   std::move(fds[1]));
       entry.recv_fds = true;
-      self->Send(&client_config_, sizeof(client_config_));
+      self->Send(&client_config_, sizeof(client_config_), -1,
+                 base::UnixSocket::BlockingMode::kBlocking);
     } else if (fds[0] || fds[1]) {
       PERFETTO_DLOG("Received partial FDs.");
     } else {
diff --git a/src/trace_processor/trace_processor_shell.cc b/src/trace_processor/trace_processor_shell.cc
index ed2d11f..487ac8f 100644
--- a/src/trace_processor/trace_processor_shell.cc
+++ b/src/trace_processor/trace_processor_shell.cc
@@ -59,7 +59,7 @@
 }
 
 bool EnsureFile(const std::string& path) {
-  return base::OpenFile(path, O_RDONLY | O_CREAT).get() != -1;
+  return base::OpenFile(path, O_RDONLY | O_CREAT, 0755).get() != -1;
 }
 
 std::string GetConfigPath() {