
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2009-02-16 17:21 byocean-city, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| fix_offset_and_resize.patch | ocean-city,2009-02-17 12:00 | |||
| Messages (6) | |||
|---|---|---|---|
| msg82253 -(view) | Author: Hirokazu Yamamoto (ocean-city)*![]() | Date: 2009-02-16 17:21 | |
This is first time to look at mmap module, so sorry if I'm sayingtotally wrong thing. (I noticed this when I sawissue2733) I think thebehavior of mmap_resize_method is unclear when mapping object is createdwith offset > 0.From view of other functions, it seems that self->offset is offset frombeginning of the file, and self->size is the size of mapped area fromself->offset. If so,#if SIZEOF_SIZE_T > 4 newSizeHigh = (DWORD)((self->offset + new_size) >> 32); newSizeLow = (DWORD)((self->offset + new_size) & 0xFFFFFFFF);#else newSizeHigh = 0; newSizeLow = (DWORD)new_size; /* shouldn't add self->offset? this isnot doing same thing as SIZEOF_SIZE_T > 4 */#endifAnd on unix part, newmap = mremap(self->data, self->size, new_size, MREMAP_MAYMOVE);self->offset is totally ignored. I think when self->offset > 0,something wrong happens.And comment above function definition saids, / Is this really necessary? This could easily be done / from python by just closing and re-opening with the / new size?I think this function is not tested well. There is no test aboutresize+offset in test_mmap.py. | |||
| msg82254 -(view) | Author: Tim Golden (tim.golden)*![]() | Date: 2009-02-16 17:25 | |
Have a look atissue 2733http://bugs.python.org/issue2733where I've just proposed a patch in this area. I'm alsonot sure exactly what's going on, but I have patched whatI believe is a linked pair of bugs in that code. | |||
| msg82256 -(view) | Author: Hirokazu Yamamoto (ocean-city)*![]() | Date: 2009-02-16 17:37 | |
Yes, I noticed this issue while investigatingissue2733. But sorry, Icouldn't reproduce the bug on my machine. Even so, LPDWORD arg forSetPointer can be modified, so your patch looks correct. (There isSetPointerEx which can make the code simpler, but this function seemsnot available on WinCE) | |||
| msg82300 -(view) | Author: Hirokazu Yamamoto (ocean-city)*![]() | Date: 2009-02-17 05:35 | |
I investigated more. Following code crashed with bus error on coLinux.import mmapdef main(): align = mmap.ALLOCATIONGRANULARITY with open("a.txt", "w") as f: f.write("0" * align) f.write("1" * align) f.write("2" * align) with open("a.txt", "r+") as f: m = mmap.mmap(f.fileno(), align, offset=align*2) m.resize(1) print m[0] # bus errorif __name__ == '__main__': main()On windows, failed with AccessDenied. (32bit Win2000) | |||
| msg82323 -(view) | Author: Hirokazu Yamamoto (ocean-city)*![]() | Date: 2009-02-17 12:00 | |
Here is a patch. | |||
| msg82337 -(view) | Author: Hirokazu Yamamoto (ocean-city)*![]() | Date: 2009-02-17 13:19 | |
I hope this is obvious too. Fixed inr69718. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:45 | admin | set | github: 49532 |
| 2009-02-17 13:19:16 | ocean-city | set | status: open -> closed resolution: fixed messages: +msg82337 |
| 2009-02-17 12:00:04 | ocean-city | set | files: +fix_offset_and_resize.patch keywords: +patch messages: +msg82323 |
| 2009-02-17 05:35:49 | ocean-city | set | type: behavior -> crash messages: +msg82300 |
| 2009-02-16 17:37:40 | ocean-city | set | messages: +msg82256 |
| 2009-02-16 17:25:40 | tim.golden | set | nosy: +tim.golden messages: +msg82254 |
| 2009-02-16 17:21:47 | ocean-city | create | |