Subject: Re: munmap(2) fails on previously mmaped large files
To: Antti Kantee <pooka@cs.hut.fi>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 05/11/2007 21:53:55
On Fri, May 11, 2007 at 10:35:22PM +0300, Antti Kantee wrote:
> On Fri May 11 2007 at 21:08:44 +0200, Nicolas Joly wrote:
> > njoly@lanfeust [embl/blastwu]> ls -l embl.*
> > -rw-r--r-- 1 997 997 12882733250 May 9 00:17 embl.xnd
> > -rw-r--r-- 1 997 997 42205936685 May 9 00:17 embl.xns
> > -rw-r--r-- 1 997 997 914661870 May 9 00:17 embl.xnt
> >
> > njoly@lanfeust [embl/blastwu]> ~/mmap ./embl.xnt
> > njoly@lanfeust [embl/blastwu]> ~/mmap ./embl.xnd
> > mmap: munmap failed: Invalid argument
> > njoly@lanfeust [embl/blastwu]> ~/mmap ./embl.xns
> > mmap: munmap failed: Invalid argument
> >
> > Here follow the ktrace output for the last command:
> >
> > 8950 1 mmap CALL open(0x7f7fffffed19,0,0x7f7fffffeba0)
> > 8950 1 mmap NAMI "./embl.xns"
> > 8950 1 mmap RET open 3
> > 8950 1 mmap CALL __fstat30(3,0x7f7fffffeaa0)
> > 8950 1 mmap RET __fstat30 0
> > 8950 1 mmap CALL mmap(0,0x9d3ab7c2d,1,1,3,0,0)
> > 8950 1 mmap RET mmap 140145487806464/0x7f762a048000
> > 8950 1 mmap CALL munmap(0x7f762a048000,0x9d3ab7c2d)
> > 8950 1 mmap RET munmap -1 errno 22 Invalid argument
>
> Does the following patch help? FWIW, I have no idea why the check is
> in there.
Yes, thanks.
> - if ((int)size < 0)
> - return (EINVAL);
In the mean time, i had a look to sys_mmap() and noticed a similar
check, except that the cast was not `int' but `ssize_t' ... and this
solved the problem too.
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.