2005-11-22 16:34:54

by Badari Pulavarty

[permalink] [raw]
Subject: mmap64() behaviour on 64-bit machines ?

Hi,

I am confused on the behaviour of mmap64() on 64-bit machines.
When I run following simple program, I get SIGSEGV in memset().
But if I replace mmap64() with mmap() - it works fine.
I verified this on ppc64, em64t, amd64.

Whats happening here ? Any clues ?

Thanks,
Badari

[root@localhost ~]# ./tst junk
Segmentation fault

strace output:
...

open("junk", O_RDWR|O_CREAT, 0644) = 3
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,
4096) = 4096
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) =
0x2aaaaaaac000
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Process 26736 detached


Attachments:
tst.c (542.00 B)

2005-11-22 20:21:29

by Nicholas Miell

[permalink] [raw]
Subject: Re: mmap64() behaviour on 64-bit machines ?

On Tue, 2005-11-22 at 08:34 -0800, Badari Pulavarty wrote:
> Hi,
>
> I am confused on the behaviour of mmap64() on 64-bit machines.
> When I run following simple program, I get SIGSEGV in memset().
> But if I replace mmap64() with mmap() - it works fine.
> I verified this on ppc64, em64t, amd64.
>
> Whats happening here ? Any clues ?

If I fix all the compiler warnings, it works for me.

Also, mmap/mmap64 return MAP_FAILED on failure, not 0, but the compiler
doesn't know to warn about that.

--
Nicholas Miell <[email protected]>