# Crash report

### What happened?

```bash
# DEV=/dev/foo
# blockdev --getsize64 $DEV
1048576
# tail $DEV
# python3.12 bug.py
Bus error (core dumped)
# tail $DEV
hell#
```

```python
from mmap import mmap

with open('/dev/foo', 'r+b') as file:
    m = mmap(file.fileno(), 1024 ** 2 + 1)

m.seek(1024 ** 2 - 4)

for b in b'hello world!':
    m.write(bytes([b]))
```

I hope you don't mind my reference to [Madagascar](https://www.imdb.com/title/tt0351283/fullcredits)


### CPython versions tested on:

3.12

### Operating systems tested on:

Linux

### Output from running 'python -VV' on the command line:

Python 3.12.3 (main, Apr 27 2024, 19:00:21) [GCC 11.4.0]
SIGBUS: writing to `mmap`ed device beyond file size
This is a GitHub Issue
repo:cpython
owner:python
Title : SIGBUS: writing to `mmap`ed device beyond file size
Issue date:

--- start body ---
# Crash report

### What happened?

```bash
# DEV=/dev/foo
# blockdev --getsize64 $DEV
1048576
# tail $DEV
# python3.12 bug.py
Bus error (core dumped)
# tail $DEV
hell#
```

```python
from mmap import mmap

with open('/dev/foo', 'r+b') as file:
    m = mmap(file.fileno(), 1024 ** 2 + 1)

m.seek(1024 ** 2 - 4)

for b in b'hello world!':
    m.write(bytes([b]))
```

I hope you don't mind my reference to [Madagascar](https://www.imdb.com/title/tt0351283/fullcredits)


### CPython versions tested on:

3.12

### Operating systems tested on:

Linux

### Output from running 'python -VV' on the command line:

Python 3.12.3 (main, Apr 27 2024, 19:00:21) [GCC 11.4.0]
--- end body ---
