[llvm-branch-commits] [compiler-rt] release/19.x: [sanitizer_common][test] Fix InternalMmapWithOffset on 32-bit Linux/s… (#101011) (PR #101142)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Aug 4 02:22:04 PDT 2024
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/101142
>From 7fc0bae294aa174ca5c1f85bb2955ededdfd6eb5 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Tue, 30 Jul 2024 09:02:05 +0200
Subject: [PATCH] =?UTF-8?q?[sanitizer=5Fcommon][test]=20Fix=20InternalMmap?=
=?UTF-8?q?WithOffset=20on=2032-bit=20Linux/s=E2=80=A6=20(#101011)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
…parc64
```
SanitizerCommon-Unit :: ./Sanitizer-sparc-Test/SanitizerCommon/InternalMmapWithOffset
```
`FAIL`s on 32-bit Linux/sparc64:
```
projects/compiler-rt/lib/sanitizer_common/tests/./Sanitizer-sparc-Test --gtest_filter=SanitizerCommon.InternalMmapWithOffset
--
compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cpp:335: Failure
Expected equality of these values:
'A'
Which is: 'A' (65, 0x41)
p[0]
Which is: '\0'
```
It turns out the `pgoffset` arg to `mmap2` is passed incorrectly in this
case, unlike the 64-bit test. The caller, `MapWritableFileToMemory`,
passes an `u64` arg, while `mmap2` expects an `off_t`. This patch casts
the arg accordingly.
Tested on `sparc64-unknown-linux-gnu` and `x86_64-pc-linux-gnu`.
(cherry picked from commit 1c25f2cd470c2882e422b66d0482f5a120960394)
---
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 76acf591871ab..1d6a55bdb7f38 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -220,7 +220,7 @@ uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
// mmap2 specifies file offset in 4096-byte units.
CHECK(IsAligned(offset, 4096));
return internal_syscall(SYSCALL(mmap2), addr, length, prot, flags, fd,
- offset / 4096);
+ (OFF_T)(offset / 4096));
# endif
}
# endif // !SANITIZER_S390
More information about the llvm-branch-commits
mailing list