From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3574 invoked by alias); 30 Sep 2003 02:06:16 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 3526 invoked from network); 30 Sep 2003 02:06:15 -0000 Received: from unknown (HELO spf13.us4.outblaze.com) (205.158.62.67) by sources.redhat.com with SMTP; 30 Sep 2003 02:06:15 -0000 Received: from 205-158-62-68.outblaze.com (205-158-62-68.outblaze.com [205.158.62.68]) by spf13.us4.outblaze.com (Postfix) with QMQP id A893D18001A7 for ; Tue, 30 Sep 2003 02:06:13 +0000 (GMT) Received: (qmail 68658 invoked from network); 30 Sep 2003 02:06:12 -0000 Received: from unknown (HELO ws5-6.us4.outblaze.com) (205.158.62.148) by 205-158-62-153.outblaze.com with SMTP; 30 Sep 2003 02:06:12 -0000 Received: (qmail 11301 invoked by uid 1001); 30 Sep 2003 02:06:12 -0000 Message-ID: <20030930020612.11298.qmail@linuxmail.org> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Received: from [192.10.200.223] by ws5-6.us4.outblaze.com with http for pgarrone@linuxmail.org; Tue, 30 Sep 2003 10:06:11 +0800 From: "peter garrone" To: cygwin@cygwin.com Date: Tue, 30 Sep 2003 02:11:00 -0000 Subject: munmap bug test program X-Originating-Ip: 192.10.200.223 X-Originating-Server: ws5-6.us4.outblaze.com X-SW-Source: 2003-09/txt/msg01813.txt.bz2 This test program highlights the recent munmap problem addressed by Corinna. It works with the updated mmap, and with linux, fails on cygwin with the prior mmap. /** * mmap test. * mmaps two chunks of adjacent memory, then munmaps one and a half, * then sees if the remainder is still useable. */ #include #include #include #include #include #include #include #ifndef _POSIX_MAPPED_FILES #warning Testing mmap/munmap, but _POSIX_MAPPED_FILES not defined. #endif #define CHUNKSIZE 0x10000 #undef Dim #define Dim(x) ((int)(sizeof(x)/sizeof(x[0]))) void * mapping1,*mapping2; char buff[CHUNKSIZE*4]; int main() { int fd; int r; int temp_open_flags; char name[] = "test_cygwin_munmapXXXXXX"; fd = mkstemp(name); assert(fd != -1); temp_open_flags = fcntl(fd, F_GETFL); assert(temp_open_flags != -1); assert((temp_open_flags & O_RDWR) == O_RDWR); /* Have to write to the file for mapping to work. */ r = write(fd, buff, sizeof(buff)); assert(r == sizeof(buff)); mapping1 = mmap(0, 2*CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); assert(mapping1 != MAP_FAILED); mapping2 = mmap(mapping1 + 2*CHUNKSIZE, 2*CHUNKSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 2*CHUNKSIZE); if(mapping2 == MAP_FAILED) { printf("OS wont do contiguous memory file mappings. Cant do test. Try changing CHUNKSIZE\n"); munmap(mapping1, 2*CHUNKSIZE); close(fd); unlink(name); exit(0); } printf("mappings: %x %x\n",mapping1,mapping2); /* Unmap from middle of first chunk to end of second chunk. */ r = munmap(mapping1 + CHUNKSIZE, 3*CHUNKSIZE); assert(r == 0); /* now try setting the first half of the first chunk */ memset(mapping1, 0, CHUNKSIZE); close(fd); /* Unmap the last bit, so hopefully the unlink of the temporary file will work. */ r = munmap(mapping1, CHUNKSIZE); assert(r == 0); r = unlink(name); assert(r == 0); return 0; } -- ______________________________________________ http://www.linuxmail.org/ Now with e-mail forwarding for only US$5.95/yr Powered by Outblaze -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/