delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/06/26/01:53:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <3EFA8A17.5FB7E72F@dessent.net>
Date: Wed, 25 Jun 2003 22:52:23 -0700
From: Brian Dessent <brian AT dessent DOT net>
Organization: My own little world...
X-Accept-Language: en,pdf
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: assertion "ptr != MAP_FAILED" failed while using mmap
References: <Pine DOT CYG DOT 4 DOT 55 DOT 0306251825330 DOT 3408 AT ellixia> <Pine DOT GSO DOT 4 DOT 44 DOT 0306251849140 DOT 22307-100000 AT slinky DOT cs DOT nyu DOT edu> <bddr4g$on$1 AT main DOT gmane DOT org>

Alex Vinokur wrote:

> char* ptr = (char*)mmap(0, sz, PROT_READ, 0, fd, 0);
> 
>    errno = 0;
>   if (ptr != MAP_FAILED)
>   {
>     string str(ptr, ptr+sz);
>     munmap(ptr, sz);
>   }
>   else
>   {
>     assert (ptr == MAP_FAILED);
>     printf ("=== Error : %u %s ===\n", errno, strerror (errno));
>   }

> The program prints:
> === Error : 0 No error ===

Of course it does, since you set errno = 0, what else could you possibly
expect?  Remove that line if you want to know why mmap() fails.

Brian

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019