This is the mail archive of the cygwin 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: mmap call gives invalid argument

On Wed, Nov 19, 2008 at 11:44 PM, Corinna Vinschen wrote:


Thanks Corinna!

> Something's going wrong with the offset, it seems.  That's a snippet
> from your strace:
>  99   60848 [main] dmidecode 540 fhandler_dev_mem::open: MemSize: 958 MB
> 108   60956 [main] dmidecode 540 open: 3 = open (/dev/mem, 0x0)
> 152   61108 [main] dmidecode 540 mmap64: addr 0, len 13783, prot 1, flags 1, fd 3, off 1005453312
>       ^^^^^^^^^^
>       Where does dmidecode get this offset from?  The address is beyond
>       the memory size available.
>  88   61196 [main] dmidecode 540 __set_errno: virtual void* fhandler_dev_mem::mmap(char**, size_t, int, int, _off64_t):1832 val 22
>  81   61277 [main] dmidecode 540 fhandler_dev_mem::mmap: -1 = mmap(): illegal parameter, set EINVAL
>  76   61353 [main] dmidecode 540 mmap64: 0xFFFFFFFF = mmap()
> What fails is a check in fhandler_dev_mem::mmap which checks that the
> address is within the valid address range.  This check is rather old.
> The last change to this function is from 2005.  The SMBIOS stuff seems
> to point outside of the valid physical memory range.
> Either the system is broken with respect to this SMBIOS data, or the
> check in Cygwin should not be made and the OS knows how to acces this
> data even though it appears to be beyond the address space.
> Try building Cygwin from scratch after disabling the first `if' statement
> in fhandler_dev_mem::mmap (file winsup/cygwin/  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.

---        2008-11-21 11:06:48.000000000 +0800
+++     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)
   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");

   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:

Is this some problem associated with accessing the device because it's 1GB?

Thank you very much.

Best Regards,

Carlo Florendo
Software Engineer
Astra Philippines - Software Development and Outsourcing
R&D:, Astra Group:

Attachment: cyg.out
Description: Binary data

Unsubscribe info:
Problem reports:

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