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

Re: LMDB test assertion failures on Linux/MIPS



Martin Lucina wrote:
Hi,

I've recently started using LMDB in a new project targeted to MIPS (and
later also ARM) architectures. While developing my storage code I found
that test cases which execute perfectly on x86 were failing with assertions
inside LMDB on mips and mipsel devices.

Investigating further, I've found that the "mtest" test program included
with LMDB also fails. Specifically, the failures I'm seeing are any of the
following:

mdb.c:2635: Assertion 'pglast <= env->me_pglast' failed in mdb_freelist_save()

or

mdb.c:5100: Assertion 'IS_BRANCH(mc->mc_pg[mc->mc_top])' failed in mdb_cursor_sibling()

or

mdb.c:5176: Assertion 'IS_LEAF(mp)' failed in mdb_cursor_next()

or

mdb.c:1713: Assertion 'rc == 0' failed in mdb_page_dirty()

etc.

The failures are intermittent in that there's about a 50% chance mtest will
complete successfully. The line numbers are against LMDB 0.9.11 source.

Target devices and toolchain combinations I have tried (all fail):

  - mips-sf-linux-musl cross compilers from musl.codu.org, musl libc 0.9.15.
    Atheros AR9344 cpu, OpenWRT trunk (Linux 3.10.28).
  - mipsel-sf-linux-musl cross compilers from musl.codu.org, musl libc
    0.9.15, Broadcom BCM4706, Tomato firmware by "shibby" (Linux 2.6.22.x
    based on ASUS SDK).

In all cases the code fails both with and without optimization, and is
compiled as a static executable.

Consulting with a friend who is also developing on MIPS devices he said he
ran into similar problems when trying LMDB. He suggested that I check for
problems with unaligned memory accesses; indeed compiling LMDB with
-Wcast-align produces many warnings regarding such accesses.

My knowledge of LMDB and MIPS internals is not up to debugging this but it
seems like unaligned accesses may(?) be the underlying cause.

That seems pretty unlikely, considering that the code works fine on SPARC which also has quite stringent alignment requirements. I presume you're compiling a 32 bit binary, not 64 bit. Perhaps shorts are bigger than 16 bits on your platform?

What is the status of LMDB on MIPS? Has anyone tried it?

Any help would be much appreciated.

Martin




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