New submission from Vinay Sharma <[email protected]>:
Consider the following python Code.
```
from multiprocessing.shared_memory import SharedMemory
shm = SharedMemory(name='test-crash', create=True, size=1000000000000000000)
```
This causes macOS Catalina, Mojave to freeze and then crash. Although, this
works fine on ubuntu.
After, debugging I realised that this is due to the ftruncate call. I could
replicate the same by calling os.ftruncate and also using ftruncate in C code.
Following C++ code also crashes, which confirms that ftruncate in macOS is
broken:
```
#include <fcntl.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <iostream>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <time.h>
int main() {
int shm_fd = shm_open("/test-shm2", O_CREAT | O_RDWR, 0666);
if (shm_fd == -1) {
throw "Shared Memory Object couldn't be created or opened";
}
int rv = ftruncate(shm_fd, (long long)1000000000000000000);
}
```
Should python, in any way handle this, so as to prevent any crashes using
python code.
----------
components: C API
messages: 361629
nosy: vinay0410
priority: normal
severity: normal
status: open
title: MacOS crashes by running attached Python code
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue39584>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com