[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
(ITS#7564) LMDB library bug: reopening LMDB may fail, fixed-address mmap
Full_Name: Tamás Kenéz
Version: LMDB 8eef7a42
OS: windows 7
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (82.141.191.242)
Using the LMDB library (commit 8eef7a4275eda) on windows 7:
To reproduce: Run mtest multiple times.
The test sometimes fails with the with the windows error code 487
(ERROR_INVALID_ADDRESS) in mdb_env_open -> mdb_env_open2 at this line
env->me_map = MapViewOfFileEx(mh, flags & MDB_WRITEMAP ?
FILE_MAP_WRITE : FILE_MAP_READ,
0, 0, env->me_mapsize, meta.mm_address);
The reason is that when windows fails to map at the specified address
(meta.mm_address) it returns 0.
I tried this quick workaround:
if ( !env->me_map )
env->me_map = MapViewOfFileEx(mh, flags & MDB_WRITEMAP ?
FILE_MAP_WRITE : FILE_MAP_READ,
0, 0, env->me_mapsize, NULL);
which does return valid address, but then it fails later here:
else if (meta.mm_address && env->me_map != meta.mm_address) {
/* Can happen because the address argument to mmap() is just a
* hint. mmap() can pick another, e.g. if the range is in use.
* The MAP_FIXED flag would prevent that, but then mmap could
* instead unmap existing pages to make room for the new map.
*/
return EBUSY; /* TODO: Make a new MDB_* error code? */