This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Buggy mmap test
- To: Zack Weinberg <zackw at stanford dot edu>, GNU Compiler <gcc at gcc dot gnu dot org>
- Subject: Buggy mmap test
- From: Bruce Korb <bkorb at sco dot COM>
- Date: Tue, 09 Jan 2001 09:40:34 -0800
- Organization: The Santa Cruz Operation
void
test_3 ()
{
char *x = anonmap (pg);
char *y = anonmap (pg);
if (x == (char *)MAP_FAILED || y == (char *)MAP_FAILED || x + pg != y)
exit (7);
Since your ``anonmap'' routine specifies a NULL address
for the address assignment, the implementation is free to
assign any address, therefore ``x + pg != y'' is likely
to fail. I modified ``anonmap'' to take an address
argument and rewrote the above as in:
void
test_3 ()
{
char *x = anonmap (pg, 0);
char *y = anonmap (pg, x+pg);
if (x == (char *)MAP_FAILED || y == (char *)MAP_FAILED) || x + pg != y)
exit (7);
if (x + pg != y)
exit (15);
and I get:
Have mmap from /dev/zero.
No mmap with MAP_ANON(YMOUS).
mmap of /dev/zero is buggy. (15)
-rw-r--r-- 1 bkorb dev 0 Jan 9 09:37 test1a.l
-rw-r--r-- 1 bkorb dev 0 Jan 9 09:37 test1z.l
-rw-r--r-- 1 bkorb dev 25 Jan 9 09:37 test2z.l
Oh, well. The addresses were:
fprintf (stderr,"0x%X != 0x%X\n",x+pg, y);
0x80002000 != 0x80003000