[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

mprotect-4 hang on Debian (and other?) implementations



Hi,

Running the binary test suite on Debian gives a reproducible hang in
LSB.os/mprotect/mprotect_P/T.mprotect_P-4 -- it leaves two processes
busy looping that'll only die (for me, anyway) with a SIGKILL.

Some investigation shows that it's actually testcase 3 that's the problem:
running tests 1-3 alone finishes, but segfaults. Likewise running test
cases 1,2,4-11 finishes with reasonable results. Running test cases 3
and 5, causes the same busy looping behaviour.

The problem seems to be the calls to mmap and munmap in test3():
vsrt_pgsz bytes are mmap'ed, then 3*vsrt_pgsz bytes are munmap'ed --
and thus anything mmap'ed in the 2*v_p bytes after our block of memory
gets munmap'ed too, and segfaults and suchlike result on accesses to
it. Presumably the sig{set,long}jmp used to check the behaviour thus
causes infinite loops. test4(), by contrast, mmap's more than it munmap's.
No idea if this actually causes problems.

test10() mmap's something, then never munmap's it. I couldn't see any
reason for this, but I couldn't see any reason for it to be a bug either.

A patch is:

--- mprotect_P.c.busted Sat Aug  3 01:22:41 2002
+++ mprotect_P.c        Sat Aug  3 01:25:18 2002
@@ -458,7 +458,7 @@
        } else
                errors += WEXITSTATUS(status);
 
-       (void)munmap((void*)adr1, (size_t)(3*vsrt_pgsz));
+       (void)munmap((void*)adr1, (size_t)(vsrt_pgsz));
 
        close(fd);
        unlink(test_file);
@@ -567,7 +567,7 @@
        } else
                errors += WEXITSTATUS(status);
 
-       munmap((void *)adr, (size_t)vsrt_pgsz);
+       munmap((void *)adr, (size_t)(3*vsrt_pgsz));
 
        unlink(test_file);
 
This change to the test suite is required for Debian to pass it cleanly.

I'm at a loss as to why this bug seems to affect Debian more than everyone
else. *shrug*

Cheers,
aj

-- 
Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG signed mail preferred.

 ``If you don't do it now, you'll be one year older when you do.''

Attachment: pgpVDmoj30puX.pgp
Description: PGP signature


Reply to: