From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24463 invoked by alias); 25 Jun 2003 15:17:18 -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 21593 invoked from network); 25 Jun 2003 14:43:56 -0000 Received: from unknown (HELO mail18.svr.pol.co.uk) (195.92.67.23) by sources.redhat.com with SMTP; 25 Jun 2003 14:43:56 -0000 Received: from modem-359.bonobo.dialup.pol.co.uk ([217.134.49.103] helo=localhost) by mail18.svr.pol.co.uk with esmtp (Exim 4.14) id 19VBUR-0000tC-Gk; Wed, 25 Jun 2003 15:43:15 +0100 Date: Wed, 25 Jun 2003 16:51:00 -0000 From: Elfyn McBratney X-X-Sender: elfyn@ellixia Reply-To: cygwin@cygwin.com To: Alex Vinokur cc: cygwin@cygwin.com Subject: Re: assertion "ptr != MAP_FAILED" failed while using mmap In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-06/txt/msg01169.txt.bz2 On Wed, 25 Jun 2003, Alex Vinokur wrote: > =========================================== > Windows 2000 > CYGWIN_NT-5.0 1.3.22(0.78/3/2) > GNU gcc version 3.2 20020927 (prerelease) > =========================================== > > Here is some function. > > -------------------------------------- > void read_file (char* filename_i) > { > int fd = open(filename_i, O_RDONLY); > assert (fd > 2); > > off_t sz = lseek(fd, 0, SEEK_END); > char* ptr = (char*)mmap(0, sz, PROT_READ, 0, fd, 0); > > assert (ptr != MAP_FAILED); // Here assertion failed > if (ptr != MAP_FAILED) > { > string str(ptr, ptr+sz); > munmap(ptr, sz); > } > > close(fd); > } > -------------------------------------- > > Assertion "ptr != MAP_FAILED)" failed. > What might cause that? This is just a stab in the dark, of course, but surely `ptr != MAP_FAILED' would indicate that the mmap did not fail? Assertions (assert()) are based on true or false, so the above assert is false in that `ptr != MAP_FAILED'. Elfyn -- -- 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/