Author vinay0410
Recipients vinay0410
Date 2020-02-08.14:18:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581171504.91.0.0818206259105.issue39584@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-02-08 14:18:24vinay0410setrecipients: + vinay0410
2020-02-08 14:18:24vinay0410setmessageid: <1581171504.91.0.0818206259105.issue39584@roundup.psfhosted.org>
2020-02-08 14:18:24vinay0410linkissue39584 messages
2020-02-08 14:18:24vinay0410create