Skip to content

Commit 1c25f2c

Browse files
authored
[sanitizer_common][test] Fix InternalMmapWithOffset on 32-bit Linux/s… (#101011)
…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`.
1 parent 7cecbdf commit 1c25f2c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
220220
// mmap2 specifies file offset in 4096-byte units.
221221
CHECK(IsAligned(offset, 4096));
222222
return internal_syscall(SYSCALL(mmap2), addr, length, prot, flags, fd,
223-
offset / 4096);
223+
(OFF_T)(offset / 4096));
224224
# endif
225225
}
226226
# endif // !SANITIZER_S390

0 commit comments

Comments
 (0)