Author mhvk
Recipients mhvk
Date 2020-05-21.21:32:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590096773.09.0.253309734553.issue40720@roundup.psfhosted.org>
In-reply-to
Content
While debugging a strange failure with tests and np.memmap, I realized that the following direct use of mmap reliably leads to a bus error. Here, obviously mmap'ing a file, closing it, opening the file for writing but not writing anything, and then again accessing the mmap is not something one should do (but a test case did it anyway), but it would nevertheless be nice to avoid a crash!
```
import mmap


with open('test.dat', 'wb') as fh:
    fh.write(b'abcdefghijklmnopqrstuvwxyz')


with open('test.dat', 'rb') as fh:
    mm = mmap.mmap(fh.fileno(), 0, access=mmap.ACCESS_READ)


with open('test.dat', 'wb') as fh:
    pass  # Note: if something is written, then I get no bus error.


mm[2]
```
History
Date User Action Args
2020-05-21 21:32:53mhvksetrecipients: + mhvk
2020-05-21 21:32:53mhvksetmessageid: <1590096773.09.0.253309734553.issue40720@roundup.psfhosted.org>
2020-05-21 21:32:53mhvklinkissue40720 messages
2020-05-21 21:32:52mhvkcreate