CDRIVER-4627 use `posix_fallocate` when available (#1244)
Avoids an unexpected crash with SIGBUS when trying to allocate a /dev/shm shared memory but there is not enough memory. Indeed ftruncate doesn't ensure memory is properly allocated, it ony changes the file size from the VFS point of view, but doesn't actually allocate any memory. So ftruncate might work despite we have no memory left, and later when trying to zero-memset the mmapped buffer, we might actually get a SIGBUS signal crashing the whole process. Instead, make sure we can allocate the whole shared memory using posix_fallocate and gracefully handle allocation problems, without crashing. The chromium project faced a similar issue in the past: https://bugs.chromium.org/p/chromium/issues/detail?id=951431
parent
2a24fef3
Please register or sign in to comment