https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/112668
>From 9571c266d478f2cb49a8005b0d19f40b3de72052 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Thu, 17 Oct 2024 15:47:37 -0700 Subject: [PATCH 1/4] rebase Created using spr 1.3.4 --- compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 2 ++ compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp index 6459c64985faab..e1117c1bec33fa 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -327,6 +327,8 @@ bool IsAccessibleMemoryRange(uptr beg, uptr size) { } bool TryMemCpy(void *dest, const void *src, uptr n) { + if (!n) + return true; int fds[2]; CHECK_EQ(0, pipe(fds)); diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp index 9e463796b2c678..03a841a6f438cb 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp @@ -16,6 +16,7 @@ # include <pthread.h> # include <sys/mman.h> +# include <algorithm> # include <numeric> # include "gtest/gtest.h" >From 2f85748304589ba78560fa8bedae42863c14c343 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Thu, 17 Oct 2024 15:51:24 -0700 Subject: [PATCH 2/4] move test into a different pr Created using spr 1.3.4 --- .../tests/sanitizer_posix_test.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp index 03a841a6f438cb..658ca60175b3bd 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_posix_test.cpp @@ -127,21 +127,6 @@ TEST(SanitizerCommon, TryMemCpyNull) { EXPECT_FALSE(TryMemCpy(dst.data(), nullptr, dst.size())); } -TEST(SanitizerCommon, TryMemCpyProtected) { - const int page_size = GetPageSize(); - InternalMmapVector<char> src(3 * page_size); - std::iota(src.begin(), src.end(), 123); - std::vector<char> dst; - // Protect the middle page. - mprotect(src.data() + page_size, page_size, PROT_NONE); - - dst.assign(src.size(), 0); - EXPECT_FALSE(TryMemCpy(dst.data(), src.data(), dst.size())); - - mprotect(src.data() + page_size, page_size, PROT_READ | PROT_WRITE); - EXPECT_TRUE(std::equal(dst.begin(), dst.end(), src.begin())); -} - } // namespace __sanitizer #endif // SANITIZER_POSIX >From 5337fadaa02592ed1e1fcdd9205ff0496c07a044 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Thu, 17 Oct 2024 16:20:05 -0700 Subject: [PATCH 3/4] EINTR Created using spr 1.3.4 --- compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp index e1117c1bec33fa..f113b8ec58a15d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -357,7 +357,10 @@ bool TryMemCpy(void *dest, const void *src, uptr n) { while (w) { uptr r = internal_read(fds[0], d, w); - CHECK(!internal_iserror(r, &e)); + if(internal_iserror(r, &e)) { + CHECK_EQ(EINTR, e); + continue; + } d += r; w -= r; >From 4e67e629322695226c4d7d0d2ee5d92effd99e53 Mon Sep 17 00:00:00 2001 From: Vitaly Buka <vitalyb...@google.com> Date: Thu, 17 Oct 2024 16:22:04 -0700 Subject: [PATCH 4/4] format Created using spr 1.3.4 --- compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp index f113b8ec58a15d..7ee2319456d23e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -357,7 +357,7 @@ bool TryMemCpy(void *dest, const void *src, uptr n) { while (w) { uptr r = internal_read(fds[0], d, w); - if(internal_iserror(r, &e)) { + if (internal_iserror(r, &e)) { CHECK_EQ(EINTR, e); continue; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits