X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Wed, 19 Nov 2008 16:44:50 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: mmap call gives invalid argument Message-ID: <20081119154450.GJ9927@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2e7d31500811190656k28244d3ev89a3c6b5ffd571e7@mail.gmail.com> User-Agent: Mutt/1.5.16 (2007-06-09) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 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, > base-mmoffset); > 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 -- 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/