[issue40720] accessing mmap of file that is overwritten causes bus error

Thomas Grainger report at bugs.python.org
Tue Mar 9 04:26:02 EST 2021


Thomas Grainger <tagrain at gmail.com> added the comment:

I can confirm this happens on py3.5-3.10

```
import mmap
import pathlib
import tempfile


def main():
    with tempfile.TemporaryDirectory() as tmp:
        tmp_path = pathlib.Path(tmp)
        path = tmp_path / "eg"

        path.write_bytes(b"Hello, World!")

        with path.open("rb") as rf:
            mm = mmap.mmap(rf.fileno(), 0, mmap.MAP_SHARED, mmap.PROT_READ)
            path.write_bytes(b"")
            bytes(mm)

if __name__ == "__main__":
    main()
```

----------
nosy: +graingert
versions: +Python 3.10, Python 3.6, Python 3.7, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40720>
_______________________________________


More information about the Python-bugs-list mailing list