[PATCH 1/4] tests/mlock2.c: fix test failure on mips64
Dmitry V. Levin
ldv at altlinux.org
Thu Aug 11 02:14:58 UTC 2016
On Wed, Aug 10, 2016 at 11:38:42AM +0100, James Cowgill wrote:
> In tests/mlock2.c, the address argument for the mlock2 syscall is passed
> through a vararg using the "syscall" function. On 64-bit systems, while the
> input argument is treated as an unsigned int, the argument is read as a
> void* (64-bits wide). On mips64, writes to the lower 32-bits of a register
> are by default sign extended to the upper 32-bits, so the pointer is read by
> the syscall function as 0xffffffffdeadbeef causing the test to fail.
> Fix by casting the integer to a void* before passing it.
> * tests/mlock2.c: add void* cast to address argument of mlock2
> tests/mlock2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/tests/mlock2.c b/tests/mlock2.c
> index af63917..59f1bf9 100644
> --- a/tests/mlock2.c
> +++ b/tests/mlock2.c
> @@ -36,7 +36,7 @@
> - long rc = syscall(__NR_mlock2, 0xdeadbeef, 0xdefaced, 0xffff);
> + long rc = syscall(__NR_mlock2, (void*) 0xdeadbeef, 0xdefaced, 0xffff);
> printf("mlock2(0xdeadbeef, 233811181, MLOCK_ONFAULT|0xfffe)"
> " = %ld %s (%m)\n", rc, errno2name());
I think 0xdeadbeefUL would also fix this test failure.
I'd even extended this test to
const unsigned long addr = (unsigned long) 0xfacefeeddeadbeefULL;
const unsigned long len = (unsigned long) 0xcafef00dbadc0dedULL;
long rc = syscall(__NR_mlock2, addr, len, -1UL);
printf("mlock2(%#lx, %lu, MLOCK_ONFAULT|0xfffffffe)"
" = %ld %s (%m)\n", addr, len, rc, errno2name());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: not available
More information about the Strace-devel