Issue 8263 - Broken cursor tracking in mdb_cursor_put()
Summary: Broken cursor tracking in mdb_cursor_put()
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-05 05:05 UTC by Hallvard Furuseth
Modified: 2015-11-30 18:28 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 Hallvard Furuseth 2015-10-05 05:05:58 UTC
Full_Name: Hallvard B Furuseth
Version: mdb.master, 8b46dcc26d1e9897ab1da3a4a164cad4a4479a52
OS: Linux x86_64
URL: ftp://ftp.openldap.org/incoming/Hallvard-Furuseth-151005.c
Submission from: (NULL) (81.191.45.5)
Submitted by: hallvard


The test program catches several cursor tracking bugs.

$ ./a.out 250
mn_flags = 0
mn_flags = 4
mn_flags = 4
a.c:36: run: Assertion `d1.mv_size == ksz && d1.mv_data == d2.mv_data' failed.
Aborted

$ ./a.out 500
mn_flags = 0
mn_flags = 4
mn_flags = 6
a.c:36: run: Assertion `d1.mv_size == ksz && d1.mv_data == d2.mv_data' failed.
Aborted

$ ./a.out 1000
mn_flags = 0
mn_flags = 6
a.c:34: mdb_cursor_get(c1, &k1, &d1, MDB_GET_CURRENT): Invalid argument
Aborted

It works when the DUPSORT sub-DB is created immediately:

$ ./a.out 1500
mn_flags = 6 <repeated 22 times>
Comment 1 Howard Chu 2015-10-07 05:37:33 UTC
h.b.furuseth@usit.uio.no wrote:
> Full_Name: Hallvard B Furuseth
> Version: mdb.master, 8b46dcc26d1e9897ab1da3a4a164cad4a4479a52
> OS: Linux x86_64
> URL: ftp://ftp.openldap.org/incoming/Hallvard-Furuseth-151005.c
> Submission from: (NULL) (81.191.45.5)
> Submitted by: hallvard
>
>
> The test program catches several cursor tracking bugs.

> It works when the DUPSORT sub-DB is created immediately:

Yes, when using a fake page we init the subcursor with the fake page. When 
using a full sub-DB we left the subcursor pointing to the sub-DB but otherwise 
uninit'd.
>
> $ ./a.out 1500
> mn_flags = 6 <repeated 22 times>

Fixed now in mdb.master.

Note: It's tempting to just merge the new xcursor_init2 function into 
xcursor_init1 since they're very similar, but that's a bad idea. The 
xcursor_init1 function really is meant for init'ing an unused cursor; it's 
expected that immediately after, a full cursor-positioning action will occur.

xcursor_init2 is meant for xcursors that have already been positioned, in 
which case their physical position is updated in order to keep their logical 
position unchanged.

-- 
   -- 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 2015-10-07 05:38:09 UTC
fixed in mdb.master
Comment 3 Howard Chu 2015-10-07 05:38:09 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 4 Hallvard Furuseth 2015-10-07 05:45:23 UTC
On 07/10/15 07:37, Howard Chu wrote:
> Note: It's tempting to just merge the new xcursor_init2 function into
> xcursor_init1 since they're very similar, but that's a bad idea. The
> xcursor_init1 function really is meant for init'ing an unused cursor;
> it's expected that immediately after, a full cursor-positioning action
> will occur.
>
> xcursor_init2 is meant for xcursors that have already been positioned,
> in which case their physical position is updated in order to keep their
> logical position unchanged.

Maybe you should document that in the code instead of in a mail message.


Comment 5 Quanah Gibson-Mount 2015-11-30 18:28:08 UTC
changed state Test to Closed