lkml.org 
[lkml]   [1998]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: mmap bug?
>>>>> "Matthew" == Matthew Kirkwood <weejock@ferret.lmh.ox.ac.uk> writes:

[someone] wrote:
>> It seems that attempts to mmap a region of size zero causes
>> mmap to return zero. Is this a bug?
>>
>> Since it doesn't return -1, it looks like success, but of
>> course dereferencing this NULL pointer causes a crash.

Zero is a multiple of the page size, so there is no partial page mapped:
the map is empty. Returning a pointer which may not be dereferenced seems
reasonable. However, mmap is explicitly forbidden from returning 0, and
SIGBUS would probably be the correct signal to deliver if an address in a
0-length map were dereferenced.

Matthew> I was just curious as to whether Unix98 or similar
Matthew> specifies any behaviour;

The zero-length case is not specifically treated.

Matthew> FWIW, Solaris (x86 and Sparc) returns -1 and sets errno
Matthew> to EINVAL. Digital Unix returns -1 and ENXIO.

EINVAL should not be returned unless MAP_FIXED is set and the address
argument is invalid. ENXIO might work, since it can occur if:
SUS2> Addresses in the range [off, off + len) are invalid for the
SUS2> object specified by fildes.


N.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:42    [W:0.052 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site