[M108 Migration] Fix crashes related to shared memory. 08/286508/6
authorBakka Uday Kiran <b.kiran@samsung.com>
Mon, 9 Jan 2023 05:56:10 +0000 (11:26 +0530)
committerBot Blink <blinkbot@samsung.com>
Tue, 10 Jan 2023 02:03:08 +0000 (02:03 +0000)
This change supresses couple of checks related to shared memory to
avoid crashes during app exit scenario and adds logs for the same.

Reference: https://review.tizen.org/gerrit/282461

Change-Id: I1466ec87f91b76fe6989a1d40c17e4cf5f496ab5
Signed-off-by: Bakka Uday Kiran <b.kiran@samsung.com>
base/files/scoped_file.cc
base/memory/platform_shared_memory_region_posix.cc

index 7ff0c17..f982697 100644 (file)
 #include "base/posix/eintr_wrapper.h"
 #endif
 
+#if BUILDFLAG(IS_TIZEN)
+#include "base/logging.h"
+#endif
+
 namespace base {
 namespace internal {
 
@@ -40,7 +44,12 @@ void ScopedFDCloseTraits::Free(int fd) {
     ret = 0;
 #endif
 
+#if BUILDFLAG(IS_TIZEN)
+  if (0 != ret)
+    LOG(ERROR) << "Failed to close file descriptor! fd=" << fd;
+#else
   PCHECK(0 == ret);
+#endif
 }
 
 #endif  // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
index 0552964..31c381c 100644 (file)
@@ -81,8 +81,20 @@ PlatformSharedMemoryRegion PlatformSharedMemoryRegion::Take(
   if (size > static_cast<size_t>(std::numeric_limits<int>::max()))
     return {};
 
+#if BUILDFLAG(IS_TIZEN)
+  if (!CheckPlatformHandlePermissionsCorrespondToMode(handle.get(), mode,
+                                                      size)) {
+    LOG(ERROR) << "CheckPlatformHandlePermissionsCorrespondToMode failed"
+               << ", fd: " << handle.get().fd
+               << ", readonly_fd: " << handle.get().readonly_fd
+               << ", mode: " << (int)mode << ", size: " << size
+               << ", guid: " << guid;
+    return {};
+  }
+#else
   CHECK(
       CheckPlatformHandlePermissionsCorrespondToMode(handle.get(), mode, size));
+#endif
 
   switch (mode) {
     case Mode::kReadOnly: