This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: assertion "ptr != MAP_FAILED" failed while using mmap


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]