[issue2733] mmap resize fails on anonymous memory (Windows)

Tim Golden report at bugs.python.org
Mon Feb 16 15:24:43 CET 2009


Tim Golden <mail at timgolden.me.uk> added the comment:

OK, I can see why this is happening and in fact there are two levels of
problem. The trouble is that, in my ignorance, I can't work out exactly
why the existing code is doing what it's doing.

(References to mmapmodule.c at r69666)

Problem 1: At line 456, the CreateFileMapping call is made with 0 hi/lo
size regardless of the file handle. cf line 1358 where it correctly
specifies the size because of the possibility of a -1 file handle. So we
now specify hi/lo values in this call. Without this change we get error
87 (invalid parameter).

Problem 2: The call to SetFilePointer at line 451 passes the hi/lo size
DWORDs. The hi value is in fact an input/output param which receives the
value of the new file pointer if a not-NULL pointer is passed in. Which
it is. This means that the hi value is now different from what it
previously was and causes an error if passed into the CreateFileMapping
call referred to in (1) above. So we make a copy of the value and ignore
the returned value. Without this change we get error 8 (not enough memory).

I'm not entirely sure what the SetFilePointer call is achieving at this
point but I'll put together a patch and a test case and perhaps someone
who understands this better can comment on the matter.

----------
nosy: +tim.golden

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2733>
_______________________________________


More information about the Python-bugs-list mailing list