delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/11/21/05:20:34

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Fri, 21 Nov 2008 11:20:28 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: mmap call gives invalid argument
Message-ID: <20081121102028.GC2982@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <2e7d31500811182249m6c38119cv67686eaaf2e1e5e1 AT mail DOT gmail DOT com> <20081119112813 DOT GG10351 AT calimero DOT vinschen DOT de> <2e7d31500811190656k28244d3ev89a3c6b5ffd571e7 AT mail DOT gmail DOT com> <20081119154450 DOT GJ9927 AT calimero DOT vinschen DOT de> <2e7d31500811201920y30c8e775wa7096411c6ac5d09 AT mail DOT gmail DOT com>
MIME-Version: 1.0
In-Reply-To: <2e7d31500811201920y30c8e775wa7096411c6ac5d09@mail.gmail.com>
User-Agent: Mutt/1.5.16 (2007-06-09)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/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

On Nov 21 11:20, Carlo Florendo wrote:
> On Wed, Nov 19, 2008 at 11:44 PM, Corinna Vinschen wrote:
> > Try building Cygwin from scratch after disabling the first `if' statement
> > in fhandler_dev_mem::mmap (file winsup/cygwin/mmap.cc).  If that helps,
> > it seems that this check is too well meant and we should better rely on
> > the OS function doing the right thing.
> 
> Ok.  I've recompiled cygwin.  I've also attached the new cygcheck.
> 
> The diff output below shows the only change I did. So essentially, we
> just let the compiler skip the if statement you mentioned.
> 
> --- mmap.cc.orig        2008-11-21 11:06:48.000000000 +0800
> +++ mmap.cc     2008-11-21 11:06:59.000000000 +0800
> @@ -1825,6 +1825,7 @@ HANDLE
>  fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot,
>                         int flags, _off64_t off)
>  {
> +#ifdef IGNORE_CFF_DMIDECODE_ISSUE
>    if (off >= mem_size
>        || (DWORD) len >= mem_size
>        || off + len >= mem_size)
> @@ -1833,6 +1834,7 @@ fhandler_dev_mem::mmap (caddr_t *addr, s
>        debug_printf ("-1 = mmap(): illegal parameter, set EINVAL");
>        return INVALID_HANDLE_VALUE;
>      }
> +#endif
> 
>    UNICODE_STRING memstr;
>    RtlInitUnicodeString (&memstr, L"\\device\\physicalmemory");
> 
> 
> In spite of that, after recompiling dmidecode with the new
> cygwin1.dll, this is what we get:
> 
> $ ./dmidecode.exe
> /dev/mem: mmap: Invalid argument
> # dmidecode 2.9
> SMBIOS 2.5 present.
> 54 structures occupying 1495 bytes.
> Table at 0x3BEE3000.
> 
> The new strace is here: http://astra.ph/research/carlo/strace2.out
> 
> Is this some problem associated with accessing the device because it's 1GB?

I don't know.  See the strace yourself:

  156  133660 [main] dmidecode 2092 mmap64: addr 0, len 13783, prot 1, flags 1, fd 3, off 1005453312
  101  133761 [main] dmidecode 2092 MapViewNT: 0 = NtMapViewOfSection (h:6F8, addr:0, len:13783, off:1005453312, protect:2, type:0)
   85  133846 [main] dmidecode 2092 seterrno_from_win_error: /home/Administrator/cygwin-1.5.25-15/winsup/cygwin/mmap.cc:1871 windows error 87
   79  133925 [main] dmidecode 2092 geterrno_from_win_error: windows error 87 == errno 22
   74  133999 [main] dmidecode 2092 __set_errno: void seterrno_from_win_error(const char*, int, DWORD):310 val 22
   82  134081 [main] dmidecode 2092 mmap64: 0xFFFFFFFF = mmap() 

Now you get the error message directly from Windows.  Unfortunately,
we don't see the actual NTSTATUS value returned by NtMapViewOfSection
because I left the value out of the debug message.  Silly me!

What you see is the converted Win32 error code 87, which is
ERROR_INVALID_PARAMETER.  The actual NTSTATUS code might give you
another hint.  Just change the debug_printf statement in the MapViewNT
function (mmap.cc line 384) to

  debug_printf ("%p (status %p) = NtMapViewOfSection (h:%x, addr:%x, len:%u,"
		" off:%D, protect:%x, type:%x)",
		base, ret, h, addr, len, off, protect, 0);

recompile, rerun, and look for the "NtMapViewOfSection" lines in
the strace output.  What's the hex status code?

However, since this fails on the native NT level, I don't think this is
just a simple Cygwin problem.  It seems that this SMBIOS stuff is
somehow broken on that system.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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