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

Re: Segmentation fault when overwriting a k/v with MDB_RESERVE ?



Simon Majou wrote:
Correction, with the flags MDB_RESERVE|MDB_APPENDDUP

What part of "DUPSORT and RESERVE are incompatible" do you not understand?

Here is the stack from gdb :

Program received signal SIGSEGV, Segmentation fault.
mdb_node_del (mc=mc@entry=0x7fffffffdb10, ksize=ksize@entry=0) at mdb.c:7183
7183                mp->mp_ptrs[j] = mp->mp_ptrs[i];
(gdb) bt
#0  mdb_node_del (mc=mc@entry=0x7fffffffdb10, ksize=ksize@entry=0)
     at mdb.c:7183
#1  0x00007ffff7bd06e2 in mdb_cursor_put (mc=0x7fffffffdb10,
     key=0x7fffffffd8d0, data=0x7fffffffd8c0, flags=<optimized out>)
     at mdb.c:6698
#2  0x00007ffff7bd0f8e in mdb_cursor_put (mc=0x7fffffffd980,
     key=0x7fffffffdd70, data=0x7fffffffdda0, flags=<optimized out>)
     at mdb.c:6757
#3  0x00007ffff7bd29b2 in mdb_put (txn=<optimized out>, dbi=<optimized out>,
     key=0x7fffffffdd70, data=0x7fffffffdda0, flags=327680) at mdb.c:8611
#4  0x0000000000400dea in main (argc=1, argv=0x7fffffffded8)
     at test_lmdb_appenddup.c:59



On 21 August 2015 at 19:25, Simon Majou <simon@majou.org
<mailto:simon@majou.org>> wrote:

    And in the case where I want to append data in a DUPSORT database, is
    there a way to write directly in the persisted page ?
    I tried with the flags MDB_RESERVE|MDB_APPEND but it fails.

    On 18 August 2015 at 15:41, Simon Majou <simon@majou.org
    <mailto:simon@majou.org>> wrote:

        Oh ok it makes sense now. Thank you for the heads up

        On 18 August 2015 at 15:36, Howard Chu <hyc@symas.com
        <mailto:hyc@symas.com>> wrote:

            Simon Majou wrote:

                This is version 0.9.16

                I used sample-bdb.txt for instance, with the DUP_SORT option,
                and the mdb_put
                with the MDB_RESERVED flags, and execute it 2 times. The first
                run (creation)
                is ok, the second (update) gets the seg fault.


            DUPSORT and RESERVED are incompatible. RESERVED means you're not
            providing a data value, only a length. DUPSORT sorts *values* -
            since you didn't provide a valid value, it probably chased a
            pointer off into space.


                I ran it in gdb and got the stack :
                #0  mdb_cursor_set (mc=mc@entry=0x7fffffffdb40,
                key=key@entry=0x7fffffffdda0,
                      data=data@entry=0x7fffffffd800, op=op@entry=MDB_SET,
                      exactp=exactp@entry=0x7fffffffd7f0) at mdb.c:5867
                #1  0x00007ffff7bd024c in mdb_cursor_put (mc=0x7fffffffdb40,
                      key=0x7fffffffdda0, data=0x7fffffffd8f0, flags=32768) at
                mdb.c:6391
                #2  0x00007ffff7bd095f in mdb_cursor_put (mc=0x7fffffffd9b0,
                      key=0x7fffffffdd90, data=0x7fffffffdda0,
                flags=<optimized out>)
                      at mdb.c:6780
                #3  0x00007ffff7bd29b2 in mdb_put (txn=<optimized out>,
                dbi=<optimized out>,
                      key=0x7fffffffdd90, data=0x7fffffffdda0, flags=65536) at
                mdb.c:8611
                #4  0x0000000000400ccf in main (argc=1, argv=0x7fffffffded8)
                at sample-mdb.c:43

                It seems the mp_lower value of the page is set to 0 instead of
                a value inside
                the page.

                On 18 August 2015 at 13:58, Howard Chu <hyc@symas.com
                <mailto:hyc@symas.com> <mailto:hyc@symas.com
                <mailto:hyc@symas.com>>>
                wrote:

                     Simon Majou wrote:

                         Hello,

                         I wonder, why do I get a Segmentation fault when I
                use mdb_put with
                         MDB_RESERVE on a key that already exists ?


                     Have no idea. Provide some more details and maybe we can
                guess.

                     LMDB version? stack trace from SEGV? What's the size of
                the existing
                     record, what's the size of the new record? Show sample
                code that
                     demonstrates the problem?

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




                --

                Best regards,

                Simon



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




        --

        Best regards,

        Simon




    --

    Best regards,

    Simon




--

Best regards,

Simon


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