Issue 8420 - lmdb Windows sizeof(off_t) == sizeof(int32_t)
Summary: lmdb Windows sizeof(off_t) == sizeof(int32_t)
Status: VERIFIED FIXED
Alias: None
Product: LMDB
Classification: Unclassified
Component: liblmdb (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-08 03:25 UTC by clayton.stangeland@gmail.com
Modified: 2020-03-12 15:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description clayton.stangeland@gmail.com 2016-05-08 03:25:58 UTC
Full_Name: Clayton Stangeland
Version: lmdb master a04aad31c2
OS: Windows 7 64 bit
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (170.54.58.5)


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.
Comment 1 Howard Chu 2016-05-11 02:39:42 UTC
clayton.stangeland@gmail.com wrote:
> Full_Name: Clayton Stangeland
> Version: lmdb master a04aad31c2
> OS: Windows 7 64 bit
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (170.54.58.5)
>
>
> This is an lmdb bug.

I see no bug here. We fixed this back in January in commit 
20dec1f69bf4860202c764ce92b1fbbe3d11a065


>
> 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.
>
>
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 OpenLDAP project 2016-05-14 04:23:18 UTC
no bug
Comment 3 Howard Chu 2016-05-14 04:23:18 UTC
changed notes
changed state Open to Closed