Subject: Re: assertion "ptr != MAP_FAILED" failed while using mmap
From: Brian Dessent <[email-masked]>
To: [email-masked]
Date: Wed, 25 Jun 2003 22:52:23 -0700

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/