mlockall() on freebsd 7.2 + amd64 returns EAGAIN
Konstantin Belousov
kostikbel at gmail.com
Wed Apr 11 04:28:43 UTC 2012
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 ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20120411/a4ce8218/attachment.pgp
More information about the freebsd-hackers
mailing list