Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!usc!samsung!xanth!mcnc!rti!mcm From: mcm@rti.UUCP (Mike Mitchell) Newsgroups: comp.os.mach Subject: Mach 2.5 bug Keywords: kernel expand(), PTE's Message-ID: <3269@rti.UUCP> Date: 16 Nov 89 00:35:56 GMT Distribution: comp Organization: Research Triangle Institute, RTP, NC Lines: 57 I have run into a problem with Mach 2.5. It is a problem that been in BSD 4.X until BSD 4.3-Tahoe. The fix is well understood for BSD type systems, but I'm not sure how it fits into the Mach kernel. The problem is that memory pages are not returned properly when using the 'brk()' library routine to free them. More specifically, the PTE entries are not invalidated properly when shrinking a region. I can supply some diffs to fix the problem for BSD systems, but I've never seen Mach source. Anyway, try running the enclosed program. Please tell me if it works on your machine, and if so, what version of Mach and the type of CPU. ------------------------------------------------------------------------- /* * This program shows off a problem with the kernel's "expand()" routine. */ #include main() { char *old_break, *cp; int i; extern char *sbrk(), *brk(); void segv(); signal(SIGSEGV, segv); i = getpagesize(); old_break = sbrk(0); /* get the current "break" */ (void) brk(old_break + 2*i); /* bump it up 2 pages */ cp = old_break + i + 256; *cp = 1; /* write into a new page */ (void) brk(old_break); /* release the memory */ *cp = 2; /* write into the page again. This */ /* time, you should get a sigsegv */ printf("Your brk routine is broken!\n"); exit(1); } void segv() { printf("Your brk routine works correctly.\n"); exit(0); } -------------------------------------------------------------------- -- Mike Mitchell {decvax,seismo,ihnp4,philabs}!mcnc!rti!mcm mcm@rti.rti.org "If you hear me talking on the wind, You've got to understand, We must remain perfect strangers" (919) 541-6098