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

Re: Compiling LMDB with Visual C++

Robin Rowe wrote:
Quanah wrote:
 > Latest is 0.9.17.

Thanks. Where's the howto or link to fetch that?

The official repo is the OpenLDAP git repo. You can also use the LMDB mirror repo on github. Relevant links are on http://www.openldap.org/

Howard wrote:
You're welcome to submit code patches against the latest code
 > in mdb.master. MSVC Project files and other such stuff
will not be accepted

Ok, thanks. How about cmake? Would you like that?

We don't use cmake.

I created a set of small C++ wrapper classes to make the API easier to use in
C++ applications. Would you like that?

We don't maintain wrappers, in any language. We leave those to 3rd parties. How are yours different from the existing C++ wrappers?


Timur wrote:
 > I'd be interested to see those code changes.

Ok, I'll make a patch after I sync up with 0.9.17 and confirm it still builds
on Linux.

Patches against 0.9.17 won't be accepted, at this point. Please read http://www.openldap.org/devel/ more carefully.

For the most part, the code changes I made were adding explicit void* casts,
which C++ is more strict about than C. I still have these VC++ warnings (in
0.9.15) that I didn't fix:

1>c:\code\lib\liblmdb\mdb.c(3892): warning C4244: '=' : conversion from
'LONGLONG' to 'size_t', possible loss of data
1>c:\code\lib\liblmdb\mdb.c(4287): warning C4244: 'argument' : conversion from
'mdb_hash_t' to 'unsigned long', possible loss of data
1>c:\code\lib\liblmdb\mdb.c(6458): warning C4146: unary minus operator applied
to unsigned type, result still unsigned
1>c:\code\lib\liblmdb\mdb.c(8859): warning C4804: '>>' : unsafe use of type
'bool' in operation
1>c:\code\lib\liblmdb\mdb.c(8860): warning C4804: '>>' : unsafe use of type
'bool' in operation

I can make these warnings go away with casts. Should I? Do any of these seem
like they may be bugs?

We don't investigate old releases. Generally, compiling C code with a C++ compiler is a mistake, since the two languages have subtle differences in integer semantics.

One bug I noticed, I encountered a segfault when opening a directory that
didn't exist and so make this change to mdb.c:

     /* For RDONLY, get lockfile after we know datafile exists */
     if (!(flags & (MDB_RDONLY|MDB_NOLOCK))) {
         rc = mdb_env_setup_locks(env, lpath, mode, &excl);
#ifndef _MSC_VER
         if (rc)
             goto leave;

This is why we don't waste our time investigating old releases. The code you're referencing has changed since 0.9.15.

The goto skips over allocating to a null pointer that is dereferenced later,
thus triggering a null pointer segfault.

If you can reproduce this in current code, please submit an actual bug report with complete stack trace to the ITS.

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