This is the mail archive of the
mailing list for the Cygwin project.
Re: mmap call gives invalid argument
On Nov 19 22:56, Carlo Florendo wrote:
> On Wed, Nov 19, 2008 at 7:28 PM, Corinna Vinschen wrote:
> > On Nov 19 14:49, Carlo Florendo wrote:
> >> Good day Cygwin gurus,
> >> $ ./dmidecode.exe
> >> # dmidecode 2.9
> >> SMBIOS 2.5 present.
> >> 54 structures occupying 1495 bytes.
> >> Table at 0x3BEE3000.
> >> /dev/mem: mmap: Invalid argument
> > Can you please extract the mmap call from the source and show it
> > to us? Apparently the new dmidecode release uses some argument
> > not supported by Cygwin (or not in this circumstances).
> Thanks Corinna.
> The file that calls mmap is:
> $ grep -nre mmap *.c
> util.c:125: * Please note that we don't use mmap() for
> performance reasons here,
> util.c:129: mmp=mmap(0, mmoffset+len, PROT_READ, MAP_SHARED, fd,
> util.c:133: perror("mmap");
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.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html