[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#8420) lmdb Windows sizeof(off_t) == sizeof(int32_t)

Full_Name: Clayton Stangeland
Version: lmdb master a04aad31c2
OS: Windows 7 64 bit
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

This is an lmdb bug.

mdb_page_flush fails as database size nears 2 GB on Windows. The reason is off_t
== int32_t on Windows. So the off_t pos variable becomes negative and this
section of code in mdb_page_flush enters the error condition as ov.OffsetHigh is
also negative:

ov.Offset = pos & 0xffffffff;
ov.OffsetHigh = pos >> 16 >> 16;
if (!WriteFile(env->me_fd, dp, size, NULL, &ov)) {
	rc = ErrCode();
	DPRINTF(("WriteFile: %d", rc));
	return rc;

Adding23dedefine off_t int64_t in an #ifdef _WIN32 region solves this.