Unverified Commit 86e23fcd authored by Romain Geissler @ Amadeus's avatar Romain Geissler @ Amadeus Committed by Kevin Albertson
Browse files

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 ef4a9a0a
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment