[ python-Bugs-1424041 ] The mmap module does unnecessary dup()

SourceForge.net noreply at sourceforge.net
Sun Feb 5 12:16:07 CET 2006


Bugs item #1424041, was opened at 2006-02-04 05:39
Message generated for change (Comment added) made by kdart
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1424041&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Keith Dart (kdart)
Assigned to: Neal Norwitz (nnorwitz)
Summary: The mmap module does unnecessary dup()

Initial Comment:
The following no longer works in Python 2.4:

_buf = mmap.mmap(-1, 8192,
flags=mmap.MAP_PRIVATE|mmap.MAP_ANONYMOUS,
prot=mmap.PROT_READ|mmap.PROT_WRITE )

This is because the fd value of -1 raises an exception
because it is being dup-ed inside the mmap module. But
the fd is ignored in anonymous mmaps and does not need
to be dup-ed. This worked in older Python (2.3). Is the
dup() call really necessary? My current workaround is
to open /dev/null. But this causes "invisible"
consumption of file descriptors for the process.

----------------------------------------------------------------------

>Comment By: Keith Dart (kdart)
Date: 2006-02-05 03:16

Message:
Logged In: YES 
user_id=16527

Bah, stupid little box... Here is the patch again. Just for
the record (no /dev/zero is needed here).


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-02-04 22:01

Message:
Logged In: YES 
user_id=33168

I think the dup() was added for resizing and some other
feature.  I'm not really sure about it, but it's safer to
leave in at this point.

There's no file attached.  This problem was fixed by patch
1407135.

Committed revision 42244.
Committed revision 42245. (2.4)


----------------------------------------------------------------------

Comment By: Keith Dart (kdart)
Date: 2006-02-04 06:33

Message:
Logged In: YES 
user_id=16527

Here is a patch that fixes the problem for anonymous maps.
It simply makes the fd to be ignored if it is less than
zero. This works, but I still don't think having a duped fd
is needed. Whatever it accomplishes could be done in Python.
As a general rule, I prefer these kinds os system call
wrappers to do as little as possible (just wrap the call). 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1424041&group_id=5470


More information about the Python-bugs-list mailing list