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
[-- Attachment #1 --]
On Tue, Apr 10, 2012 at 06:33:44PM -0700, Sushanth Rai wrote:
>
> > > 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:
> > >
> > > if (fs.pindex >= fs.object->size) {
> > >š š
> > šššunlock_and_deallocate(&fs);
> > >š š šššreturn
> > (KERN_PROTECTION_FAILURE);
> > > }
> > >
> > > Any help would be appreciated.
> >
> > This might be a bug fixed in r191810, but I am not sure.
> >
>
> 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:
>
> open("/lib/libm.so.5",O_RDONLY,030577200) = 3 (0x3)
> fstat(3,{ mode=-r--r--r-- ,inode=918533,size=115560,blksize=4096 }) = 0 (0x0)
> read(3,"\^?ELF\^B\^A\^A\t\0\0\0\0\0\0\0"...,4096) = 4096 (0x1000)
> mmap(0x0,1155072,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_NOCORE,3,0x0) = 34366242816 (0x800634000)
>
> So the size of the file is 115560 but mmap() length is 1155072. The memory map of the file corresponding to libm as seen from running 'cat /proc/<mypid>/map' is the following:
>
> 0x800634000 0x80064c000 24 0 0xffffff002553eca8 r-x 108 54 0x0 COW NC vnode /lib/libm.so.5
> 0x80064c000 0x80064d000 1 0 0xffffff01d79b0a20 r-x 1 0 0x3100 COW NNC vnode /lib/libm.so.5
> 0x80064d000 0x80074c000 3 0 0xffffff002553eca8 r-x 108 54 0x0 COW NC vnode /lib/libm.so.5
> 0x80074c000 0x80074e000 2 0 0xffffff01d79f1288 rw- 1 0 0x3100 COW NNC vnode /lib/libm.so.5
>
>
> when the program tries to fault-in all the pages as part of call to mlockall(), the following check in vm_fault() fails when trying to fault-in 0x800651000.
>
> if (fs.pindex >= fs.object->size) {
> unlock_and_deallocate(&fs);
> return (KERN_PROTECTION_FAILURE);
> }
>
> since the object size corresponds to size of libm and fault address is one page beyond the object size. Is this a bug ?
Then it should be fixed in r190885.
Could you use something less antique, please ?
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)
iEYEARECAAYFAk+FCHUACgkQC3+MBN1Mb4ji0QCfYZ9D9iptL5BNKYa1pyOoNYgt
dpoAnR/NGj9SfNW2VrQ2d42QnIFLVJIT
=Taew
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120411042837.GD2358>
