Date: Wed, 11 Apr 2012 07:28:37 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Sushanth Rai <sushanth_rai@yahoo.com> Cc: freebsd-hackers@freebsd.org Subject: Re: mlockall() on freebsd 7.2 + amd64 returns EAGAIN Message-ID: <20120411042837.GD2358@deviant.kiev.zoral.com.ua> In-Reply-To: <1334108024.348.YahooMailClassic@web180005.mail.gq1.yahoo.com> References: <20120410095726.GU2358@deviant.kiev.zoral.com.ua> <1334108024.348.YahooMailClassic@web180005.mail.gq1.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--wmY+ywD75ArFSrfn Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 10, 2012 at 06:33:44PM -0700, Sushanth Rai wrote: >=20 > > > I don't know if that has anything to do with failure. > > The snippet of code that returns failure in vm_fault() is > > the following: > > >=20 > > > if (fs.pindex >=3D fs.object->size) { > > >=9A =9A > > =9A=9A=9Aunlock_and_deallocate(&fs); > > >=9A =9A =9A=9A=9Areturn > > (KERN_PROTECTION_FAILURE); > > > } > > >=20 > > > Any help would be appreciated. > >=20 > > This might be a bug fixed in r191810, but I am not sure. > >=20 >=20 > I tried that fix but it didn't work. What seems to happen is that libm is= mmap'ed beyond the size of the file. From truss o/p, I see the following: >=20 > open("/lib/libm.so.5",O_RDONLY,030577200) =3D 3 (0x3) > fstat(3,{ mode=3D-r--r--r-- ,inode=3D918533,size=3D115560,blksize=3D4096 = }) =3D 0 (0x0) > read(3,"\^?ELF\^B\^A\^A\t\0\0\0\0\0\0\0"...,4096) =3D 4096 (0x1000) > mmap(0x0,1155072,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_NOCORE,3,0x0) =3D 34= 366242816 (0x800634000) >=20 > So the size of the file is 115560 but mmap() length is 1155072. The memor= y map of the file corresponding to libm as seen from running 'cat /proc/<my= pid>/map' is the following: >=20 > 0x800634000 0x80064c000 24 0 0xffffff002553eca8 r-x 108 54 0x0 COW NC vno= de /lib/libm.so.5 > 0x80064c000 0x80064d000 1 0 0xffffff01d79b0a20 r-x 1 0 0x3100 COW NNC vno= de /lib/libm.so.5 > 0x80064d000 0x80074c000 3 0 0xffffff002553eca8 r-x 108 54 0x0 COW NC vnod= e /lib/libm.so.5 > 0x80074c000 0x80074e000 2 0 0xffffff01d79f1288 rw- 1 0 0x3100 COW NNC vno= de /lib/libm.so.5 >=20 >=20 > when the program tries to fault-in all the pages as part of call to mlock= all(), the following check in vm_fault() fails when trying to fault-in 0x80= 0651000. >=20 > if (fs.pindex >=3D fs.object->size) { > unlock_and_deallocate(&fs); > return (KERN_PROTECTION_FAILURE); > } >=20 > since the object size corresponds to size of libm and fault address is on= e page beyond the object size. Is this a bug ? Then it should be fixed in r190885. Could you use something less antique, please ? --wmY+ywD75ArFSrfn Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk+FCHUACgkQC3+MBN1Mb4ji0QCfYZ9D9iptL5BNKYa1pyOoNYgt dpoAnR/NGj9SfNW2VrQ2d42QnIFLVJIT =Taew -----END PGP SIGNATURE----- --wmY+ywD75ArFSrfn--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120411042837.GD2358>