Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Reply-To: From: "Shane Mann" To: Subject: RE: cygwin 1.3.3 WinNT4.0 munmap invalid argument Date: Thu, 27 Jun 2002 10:13:30 +1000 Message-ID: <001c01c21d6f$774f5b60$8e90a8c0@citr.com.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_001D_01C21DC3.48FB6B60" X-Priority: 3 (Normal) X-MSMail-Priority: Normal In-Reply-To: <20020626100748.N22705@cygbert.vinschen.de> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal X-MailScanner: Found to be clean ------=_NextPart_000_001D_01C21DC3.48FB6B60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit OK - I wasn't sure what the list would be like - after 100+ emails overnight I see it is quite active. I have created a test case - hopefully it's not to hard to follow. I can compile and run it under redhat linux with no errors, but not under cygwin. There are 2 parts, the c code (munmap_test.c) and a text file (cygcheck.out) - as the mapping is using a file descriptor. I thought it may be useful to make the text file the output from cygwin configuration diagnostics. In both cases gcc with no other options was used to compile. Thanks in Advance, Shane Shane Mann Software Engineer Phone: +61-7-3259-2223 CiTR Pty Ltd Fax: +61-7-3259-2259 339 Coronation Drive, Email: shanem AT citr DOT com DOT au Milton, QLD, 4064 Web: http://www.citr.com.au > -----Original Message----- > From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com]On Behalf > Of Corinna Vinschen > Sent: Wednesday, 26 June 2002 18:08 > To: cygwin AT cygwin DOT com > Subject: Re: cygwin 1.3.3 WinNT4.0 munmap invalid argument > > > On Wed, Jun 26, 2002 at 02:15:43PM +1000, Shane Mann wrote: > > Hi, > > > > I am having trouble with a munmap call failing with an invalid argument. > > munmap seems to have 3 error conditions, I can eliminate 2 of those (len > > <=0, and mem block size not divisible by page size), which leave me with > > address + size outside process memory space. Is this a common problem? > > Following is some debug output: > > > > Just Mmaped 20480 which is now at address 1A440000 > > > > About to UnMapp 20480 at 1A440000 > > > > The code works fine under Linux but falls over with munmap: > Invalid Argument > > under cygwin gcc. > > > > Any help appreciated. > > Not enough info. Please create a *simple* testcase and send it to > this list. > > Corinna > > -- > Corinna Vinschen Please, send mails regarding Cygwin to > Cygwin Developer mailto:cygwin AT cygwin DOT com > Red Hat, Inc. > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Bug reporting: http://cygwin.com/bugs.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > ------=_NextPart_000_001D_01C21DC3.48FB6B60 Content-Type: application/octet-stream; name="munmap_test.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="munmap_test.c" #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= =0A= =0A= /************************************************************************= *****/=0A= /* = */=0A= /* Front ends to various library calls = */=0A= /* = */=0A= /************************************************************************= *****/=0A= =0A= =0A= static int syspagesize =3D 0, pagemask, offmask;=0A= =0A= caddr_t femmap(int fd, off_t foff, size_t syz, int prot, u_char *msg) {=0A= /* femmap() and fem/unmap() take care of the need to allocate =0A= on page boundaries and in multiples of pages. */=0A= off_t pfoff; /* foff on a page boundary */=0A= size_t psyz; /* syz rounded up to full pages */=0A= int chopped;=0A= caddr_t rslt;=0A= if (syspagesize =3D=3D 0) {=0A= syspagesize =3D getpagesize();=0A= offmask =3D syspagesize - 1;=0A= pagemask =3D ~offmask;=0A= if (0) printf("--- Syspagesize %d, pagemask %X, offmask %X\n", =0A= syspagesize, pagemask, offmask);=0A= }=0A= pfoff =3D foff & pagemask;=0A= chopped =3D foff & offmask;=0A= psyz =3D (syz + chopped + syspagesize - 1) & pagemask;=0A= =0A= =0A= =0A= if ((rslt =3D mmap(0, psyz, prot, MAP_SHARED, =0A= fd, pfoff)) =3D=3DMAP_FAILED) {=0A= fprintf(stderr,"Error: %s\n", msg);=0A= perror("Mmap");=0A= exit(201);=0A= }=0A= =0A= printf("Just Mmaped %d which is now at address %X\n", psyz, (int)rslt);=0A= =0A= if (0)=0A= printf(" Mapping %d at %X <---> %d (%s\n", psyz, (int)rslt, = (int)pfoff, =0A= msg);=0A= return (rslt + chopped);=0A= }=0A= =0A= void femunmap(caddr_t cad, size_t syz, u_char *msg) {=0A= /* Unmap the specified block of memory. Cad should be the result=0A= returned by a call to femmap() and syz should be the size =0A= passed to femmap()=0A= =0A= */=0A= size_t psyz; /* syz rounded up to full pages */=0A= int chopped;=0A= caddr_t pcad;=0A= =0A= chopped =3D (int) cad & offmask;=0A= pcad =3D (caddr_t) ((int) cad & pagemask);=0A= psyz =3D (syz + chopped + syspagesize - 1) & pagemask;=0A= =0A= printf("About to UnMapp %d at %X\n", psyz, (int)pcad);=0A= =0A= if (munmap(pcad, psyz)) {=0A= perror(msg);=0A= exit(205);=0A= }=0A= if (0)=0A= printf(" UnMapping %d at %X - (%s)\n", psyz, (int)pcad, msg);=0A= =0A= }=0A= =0A= static off_t bnsyz;=0A= static u_char *bnams;=0A= =0A= int=0A= main(void)=0A= {=0A= int tfd;=0A= u_char filename[100];=0A= struct stat finfo;=0A= =0A= strcpy(filename, "cygcheck.out");=0A= =0A= tfd =3D open(filename, O_RDONLY, 0);=0A= =0A= fstat(tfd, &finfo);=0A= =0A= bnsyz =3D finfo.st_size;=0A= =0A= bnams =3D femmap(tfd, 0, bnsyz, PROT_READ, "bnams");=0A= =0A= if (bnams !=3D NULL) {=0A= femunmap(bnams, bnsyz, "bnams");=0A= bnams =3D NULL;=0A= }=0A= =0A= return(0);=0A= }=0A= ------=_NextPart_000_001D_01C21DC3.48FB6B60 Content-Type: application/octet-stream; name="cygcheck.out" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="cygcheck.out" =0A= Cygnus Win95/NT Configuration Diagnostics=0A= Current System Time: Wed Jun 26 14:06:11 2002=0A= =0A= WinNT Ver 4.0 build 1381 Service Pack 6=0A= =0A= Path: /home/shanem/bin=0A= /home/shanem/ap101/007.source=0A= /home/shanem/bin=0A= /home/shanem/ap101/007.source=0A= /usr/local/bin=0A= /usr/bin=0A= /bin=0A= /cygdrive/c/Perl/bin/=0A= /cygdrive/d/oracle/ora81/bin=0A= /cygdrive/c/Program Files/Oracle/jre/1.1.7/bin=0A= /cygdrive/c/WINNT/system32=0A= /cygdrive/c/WINNT=0A= /cygdrive/d/mssql7/BINN=0A= /cygdrive/c/Program Files/Mts=0A= /cygdrive/c/Program Files/Microsoft Visual Studio/Common/Tools/WinNT=0A= /cygdrive/c/Program Files/Microsoft Visual Studio/Common/MSDev98/Bin=0A= /cygdrive/c/Program Files/Microsoft Visual Studio/Common/Tools=0A= /cygdrive/c/Program Files/Microsoft Visual Studio/VC98/bin=0A= /cygdrive/c/jdk1.2.2/bin=0A= /cygdrive/c/jdk1.2.2/lib=0A= /cygdrive/c/jdk1.2.2/bin=0A= /cygdrive/c/jdk1.2.2/lib=0A= =0A= SysDir: C:\WINNT\System32=0A= WinDir: C:\WINNT=0A= =0A= PWD =3D `/home/shanem/c'=0A= USER =3D `shanem'=0A= MAKE_MODE =3D `unix'=0A= HOME =3D `/home/shanem'=0A= =0A= NUMBER_OF_PROCESSORS =3D `1'=0A= PROMPT =3D `$P$G'=0A= LOGONSERVER =3D `\\SHANEM'=0A= OS2LIBPATH =3D `C:\WINNT\system32\os2\dll;'=0A= COLORFGBG =3D `15;default;0'=0A= JAVAC =3D `/cygdrive/c/jdk1.3.1_01/bin/javac.exe'=0A= COMSPEC =3D `C:\WINNT\system32\cmd.exe'=0A= WINDOWID =3D `167843632'=0A= !C: =3D `C:\cygwin\bin'=0A= SYSTEMDRIVE =3D `C:'=0A= HOSTNAME =3D `SHANEM'=0A= INCLUDE =3D `C:\Program Files\Microsoft Visual = Studio\VC98\atl\include;C:\Program Files\Microsoft Visual = Studio\VC98\mfc\include;C:\Program Files\Microsoft Visual = Studio\VC98\include'=0A= PROCESSOR_REVISION =3D `0703'=0A= PATHEXT =3D `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH'=0A= COMPUTERNAME =3D `SHANEM'=0A= WINDIR =3D `C:\WINNT'=0A= USERPROFILE =3D `C:\WINNT\Profiles\shanem.000'=0A= PS1 =3D `\w>'=0A= PROJECT =3D `/home/shanem/ap101'=0A= SEARCH_HOME =3D `/cygdrive/c/cygwin/home/shanem/search_home'=0A= MACHTYPE =3D `i686-pc-cygwin'=0A= PROCESSOR_IDENTIFIER =3D `x86 Family 6 Model 7 Stepping 3, GenuineIntel'=0A= OS =3D `Windows_NT'=0A= OLDPWD =3D `/home/shanem'=0A= PROCESSOR_ARCHITECTURE =3D `x86'=0A= TEMP =3D `/cygdrive/c/TEMP'=0A= PROCESSOR_LEVEL =3D `6'=0A= SYSTEMROOT =3D `C:\WINNT'=0A= COLORTERM =3D `rxvt-xpm'=0A= TMP =3D `/cygdrive/c/TEMP'=0A= HOMEDRIVE =3D `C:'=0A= LIB =3D `C:\Program Files\Microsoft Visual = Studio\VC98\mfc\lib;C:\Program Files\Microsoft Visual Studio\VC98\lib'=0A= DISPLAY =3D `:0'=0A= SHLVL =3D `3'=0A= DIRCMD =3D `/w/p/o/a'=0A= HOMEPATH =3D `\'=0A= USERDOMAIN =3D `SHANEM'=0A= USERNAME =3D `shanem'=0A= SHELL =3D `/bin/bash'=0A= HOSTTYPE =3D `i686'=0A= CVSROOT =3D `/home/shanem/ap101/007.source/.CVSROOT_Panoptic'=0A= OSTYPE =3D `cygwin'=0A= TERM =3D `xterm'=0A= _ =3D `/usr/bin/cygcheck'=0A= TZ =3D `EAST-10'=0A= =0A= HKEY_CURRENT_USER\Software\Cygnus Solutions=0A= HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin=0A= HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2=0A= (default) =3D `/cygdrive'=0A= cygdrive flags =3D 0x00000022=0A= HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/=0A= (default) =3D `C:/cygwin'=0A= flags =3D 0x0000000a=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin=0A= (default) =3D `C:/cygwin/bin'=0A= flags =3D 0x0000000a=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib=0A= (default) =3D `C:/cygwin/lib'=0A= flags =3D 0x0000000a=0A= HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options=0A= =0A= a: fd N/A N/A =0A= c: hd NTFS 4348Mb 87% CP CS UN PA FC BOOT=0A= d: hd NTFS 3713Mb 62% CP CS UN PA FC Work=0A= e: cd N/A N/A =0A= f: net Samba 4063Mb 78% CP UN shanem=0A= h: net FAT 9615Mb 88% CP UN PRETZEL=0A= =0A= C:\cygwin\bin /usr/bin system binmode=0A= C:\cygwin\lib /usr/lib system binmode=0A= C:\cygwin / system binmode=0A= c: /cygdrive/c user binmode,noumount=0A= d: /cygdrive/d user binmode,noumount=0A= f: /cygdrive/f user binmode,noumount=0A= h: /cygdrive/h user binmode,noumount=0A= =0A= Found: C:\cygwin\bin\bash.exe=0A= Found: C:\cygwin\bin\cat.exe=0A= Found: C:\cygwin\bin\cpp.exe=0A= Found: C:\cygwin\bin\find.exe=0A= Found: C:\cygwin\bin\gcc.exe=0A= Found: C:\cygwin\bin\gdb.exe=0A= Found: C:\cygwin\bin\ld.exe=0A= Found: C:\cygwin\bin\ls.exe=0A= Found: C:\cygwin\bin\make.exe=0A= Found: C:\cygwin\bin\sh.exe=0A= =0A= 701k 2001/09/13 C:\WINNT\cygwin1.dll - os=3D4.0 img=3D1.0 sys=3D4.0=0A= "cygwin1.dll" v0.0 ts=3D2001/9/13 13:54=0A= Cygwin DLL version info:=0A= dll major: 1003=0A= dll minor: 3=0A= dll epoch: 19=0A= dll bad signal mask: 19005=0A= dll old termios: 5=0A= dll malloc env: 28=0A= api major: 0=0A= api minor: 46=0A= shared data: 3=0A= dll identifier: cygwin1=0A= mount registry: 2=0A= cygnus registry name: Cygnus Solutions=0A= cygwin registry name: Cygwin=0A= program options name: Program Options=0A= cygwin mount registry name: mounts v2=0A= cygdrive flags: cygdrive flags=0A= cygdrive prefix: cygdrive prefix=0A= cygdrive default prefix: =0A= build date: Wed Sep 12 23:54:31 EDT 2001=0A= shared id: cygwin1S3=0A= =0A= 56k 2000/12/03 C:\cygwin\bin\cygbz21.0.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygbz21.0.dll" v0.0 ts=3D2000/11/21 9:53=0A= 45k 2001/04/25 C:\cygwin\bin\cygform5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygform5.dll" v0.0 ts=3D2001/4/25 15:28=0A= 34k 2001/09/30 C:\cygwin\bin\cygform6.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygform6.dll" v0.0 ts=3D2001/9/30 12:43=0A= 18k 2000/10/23 C:\cygwin\bin\cyggdbm.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cyggdbm.dll" v0.0 ts=3D2000/10/23 12:26=0A= 17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cyghistory4.dll" v0.0 ts=3D2001/1/7 14:34=0A= 21k 2001/06/28 C:\cygwin\bin\cyghistory5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cyghistory5.dll" v0.0 ts=3D2001/6/28 12:27=0A= 21k 2001/06/20 C:\cygwin\bin\cygintl.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygintl.dll" v0.0 ts=3D2001/6/21 3:09=0A= 81k 2000/12/05 C:\cygwin\bin\cygitcl30.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygitcl30.dll" v0.0 ts=3D2000/11/26 11:43=0A= 35k 2000/12/05 C:\cygwin\bin\cygitk30.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygitk30.dll" v0.0 ts=3D2000/11/26 11:43=0A= 45k 2001/07/04 C:\cygwin\bin\cygjbig1.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygjbig1.dll" v0.0 ts=3D2001/7/4 13:25=0A= 119k 2001/06/06 C:\cygwin\bin\cygjpeg6b.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygjpeg6b.dll" v0.0 ts=3D2001/6/6 14:27=0A= 26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygmenu5.dll" v0.0 ts=3D2001/4/25 15:27=0A= 19k 2001/09/30 C:\cygwin\bin\cygmenu6.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygmenu6.dll" v0.0 ts=3D2001/9/30 12:43=0A= 156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygncurses++5.dll" v0.0 ts=3D2001/4/25 15:29=0A= 175k 2001/09/30 C:\cygwin\bin\cygncurses++6.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygncurses++6.dll" v0.0 ts=3D2001/9/30 12:45=0A= 226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygncurses5.dll" v0.0 ts=3D2001/4/25 15:17=0A= 201k 2001/09/30 C:\cygwin\bin\cygncurses6.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygncurses6.dll" v0.0 ts=3D2001/9/30 12:42=0A= 15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygpanel5.dll" v0.0 ts=3D2001/4/25 15:27=0A= 12k 2001/09/30 C:\cygwin\bin\cygpanel6.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygpanel6.dll" v0.0 ts=3D2001/9/30 12:43=0A= 163k 2001/05/06 C:\cygwin\bin\cygpng2.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygpng2.dll" v0.0 ts=3D2001/5/6 14:05=0A= 108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygreadline4.dll" v0.0 ts=3D2001/1/7 14:34=0A= 135k 2001/06/28 C:\cygwin\bin\cygreadline5.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygreadline5.dll" v0.0 ts=3D2001/6/28 12:27=0A= 390k 2000/12/05 C:\cygwin\bin\cygtcl80.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygtcl80.dll" v0.0 ts=3D2000/11/26 11:39=0A= 5k 2000/12/05 C:\cygwin\bin\cygtclpip80.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= 10k 2000/12/05 C:\cygwin\bin\cygtclreg80.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygtclreg80.dll" v0.0 ts=3D2000/11/26 11:39=0A= 245k 2001/06/12 C:\cygwin\bin\cygtiff3.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygtiff3.dll" v0.0 ts=3D2001/6/13 3:25=0A= 623k 2000/12/05 C:\cygwin\bin\cygtk80.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygtk80.dll" v0.0 ts=3D2000/11/26 11:43=0A= 41k 2001/07/04 C:\cygwin\bin\cygXpm-noX4.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygXpm-noX4.dll" v0.0 ts=3D2001/7/4 11:21=0A= 45k 2001/07/04 C:\cygwin\bin\cygXpm-X4.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygXpm-X4.dll" v0.0 ts=3D2000/11/20 12:45=0A= 49k 2001/02/03 C:\cygwin\bin\cygz.dll - os=3D4.0 img=3D1.0 sys=3D4.0=0A= "cygz.dll" v0.0 ts=3D2001/2/4 6:35=0A= 701k 2001/09/13 C:\cygwin\bin\cygwin1.dll - os=3D4.0 img=3D1.0 = sys=3D4.0=0A= "cygwin1.dll" v0.0 ts=3D2001/9/13 13:54=0A= Cygwin DLL version info:=0A= dll major: 1003=0A= dll minor: 3=0A= dll epoch: 19=0A= dll bad signal mask: 19005=0A= dll old termios: 5=0A= dll malloc env: 28=0A= api major: 0=0A= api minor: 46=0A= shared data: 3=0A= dll identifier: cygwin1=0A= mount registry: 2=0A= cygnus registry name: Cygnus Solutions=0A= cygwin registry name: Cygwin=0A= program options name: Program Options=0A= cygwin mount registry name: mounts v2=0A= cygdrive flags: cygdrive flags=0A= cygdrive prefix: cygdrive prefix=0A= cygdrive default prefix: =0A= build date: Wed Sep 12 23:54:31 EDT 2001=0A= shared id: cygwin1S3=0A= =0A= Use -h to see help about each section=0A= ------=_NextPart_000_001D_01C21DC3.48FB6B60 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ------=_NextPart_000_001D_01C21DC3.48FB6B60--