Bug #1065
closedgthread_aio/posix_aio: mmap() fails on OS X.
Description
The gthread_aio and posix_aio backends are broken on OS X. OS X doesn't support using /dev/zero file descriptor for anonymous shared memory isn't supported. It results in this error getting repeated when debugging is enabled:
network_posix_aio.c.348: (error) the mmap() failed, no way for a fallback:
connections.c.1336: (trace) (network-subsys sent us a fatal-error)
To avoid this problem I replaced this line in src/network_gthread_aio.c (~ line 101):
c->file.mmap.start = mmap(0, c->file.mmap.length,
PROT_READ | PROT_WRITE, MAP_SHARED, mmap_fd, 0);
With:
c->file.mmap.start = mmap(0, c->file.mmap.length,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
Doing the same thing with src/network_posix_aio.c (~ line 348) prevents the error when using that backend.
Obviously this isn't the best way to fix the problem, the /dev/zero fd is still created and this probably breaks the code for other operating systems. Note that MAP_ANON may be called MAP_ANONYMOUS on other OSes.
Files
Updated by jwmcglynn almost 18 years ago
After looking through manpages (http://ou800doc.caldera.com/en/man/html.2/mmap.2.html), it appears that the only difference between using mmap with a /dev/zero fd and MAP_ANONYMOUS is speed, with MAP_ANONYMOUS being faster.
I'm adding this patch so that you can test it, it works on OS X and doesn't crash on Linux, but I haven't tested it on any other operating systems.
Updated by jwmcglynn over 17 years ago
- Status changed from New to Fixed
- Resolution set to fixed
Fixed in r1757.
Also available in: Atom