[llvm-branch-commits] [sanitizer] Add TryMemCpy (PR #112668)

Florian Mayer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 17 12:53:43 PDT 2024


================
@@ -325,6 +325,44 @@ bool IsAccessibleMemoryRange(uptr beg, uptr size) {
   return true;
 }
 
+bool TryMemCpy(void *dest, const void *src, uptr n) {
+  int sock_pair[2];
+  if (pipe(sock_pair))
+    return false;
+
+  auto cleanup = at_scope_exit([&]() {
+    internal_close(sock_pair[0]);
+    internal_close(sock_pair[1]);
+  });
+
+  SetNonBlock(sock_pair[0]);
----------------
fmayer wrote:

Actually maybe not. Because we always read after writing, so there should always be space in the buffer for writing, and always be data for reading.

But we need to handle EINTR.

https://github.com/llvm/llvm-project/pull/112668


More information about the llvm-branch-commits mailing list