mmap call gives invalid argument
Carlo Florendo
subscribermail@gmail.com
Fri Nov 21 14:58:00 GMT 2008
On Wed, Nov 19, 2008 at 11:44 PM, Corinna Vinschen wrote:
<snip>
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/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?
Thank you very much.
Best Regards,
Carlo
--
Carlo Florendo
Software Engineer
Astra Philippines - Software Development and Outsourcing
R&D: http://astra.ph, Astra Group: http://astra.co.jp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cyg.out
Type: application/octet-stream
Size: 35247 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20081121/33f6e8db/attachment.obj>
-------------- next part --------------
--
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/
More information about the Cygwin
mailing list