This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Buggy mmap test




   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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]