On Mon, Jul 10, 2017 at 07:34:11AM +0000, Stuart Henderson wrote:

> Feel free to try it, I believe the required patch to force MDB_WRITEMAP
> is still in there..but I don't think there were any major changes upstream
> since the last attempt so I wouldn't hold out too much hope for it working
> straight off.

Hmm, as you said, trying to use mdb resulted in crashes. My initial debugging
led to the cause of this as a NULL mdb environment, and ironically the
root cause of that turned out to be the OpenBSD specific MDB_WRITEMAP
patch 8-/.

        if ( !(flags & MDB_WRITEMAP) ) {
                Debug( LDAP_DEBUG_ANY,
                        LDAP_XSTRING(mdb_db_open) ": database \"%s\" does not 
have writemap. "
                        "This is required on systems without unified buffer 
cache.\n",
                        be->be_suffix[0].bv_val, rc, 0 );
                goto fail;
        }

There are two problems with it; first, it accesses the local flags variable
before it is initialized to mdb->mi_dbenv_flags shortly thereafter, so the
value checked is random and the if block nondeterministically triggers, and
second, it doesn't assign a failure value to rc before it jumps to fail, so
the function returns successfully but with a closed be, and the code keeps
going but later segfaults because of the NULL mdb environment.

I updated the patch and moved the check to be after the flags initialization:

        flags = mdb->mi_dbenv_flags;

and added an assignment to rc on failure:

        rc = MDB_INCOMPATIBLE;

I then tweaked the mdb test suite to always enable MDB_WRITEMAP, and so far
it's been running for 20 minutes with no errors, crashes, or failures.

Right now it's compiled "-O0 -ggdb", if everything keeps looking good, I'll
recompile it normally and do more testing.

Reply via email to