Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ns-slapd dbverify fails with segfault #3753

Closed
389-ds-bot opened this issue Sep 13, 2020 · 6 comments
Closed

ns-slapd dbverify fails with segfault #3753

389-ds-bot opened this issue Sep 13, 2020 · 6 comments
Labels
closed: duplicate Migration flag - Issue

Comments

@389-ds-bot
Copy link

Cloned from Pagure issue: https://pagure.io/389-ds-base/issue/50698

  • Created at 2019-11-11 04:57:28 by sgmt
  • Closed at 2019-11-14 17:50:54 as duplicate
  • Assigned to nobody

Issue Description

ns-slapd dbverify fails with segfault.

The backtrace is as follows.

Core was generated by `/opt/dirsrv/sbin/ns-slapd dbverify -D /etc/dirsrv/slapd-localhost4/'.
Program terminated with signal SIGSEGV, Segmentation fault.
0  0x00007fac05f9f26c in ldbm_back_dbverify (pb=0x9f3520) at ldap/servers/slapd/back-ldbm/dbverify.c:25
25      return priv->dblayer_verify_fn(pb);;
(gdb) bt
0  0x00007fac05f9f26c in ldbm_back_dbverify (pb=0x9f3520) at ldap/servers/slapd/back-ldbm/dbverify.c:25
1  0x000000000040f26c in slapd_exemode_dbverify (mcfg=<optimized out>) at ldap/servers/slapd/main.c:2629
2  main (argc=4, argv=<optimized out>) at ldap/servers/slapd/main.c:865
(gdb) p priv
$1 = (dblayer_private *) 0x0

I suspect that ns-slapd forgets to initialize dblayer_private of ldbm database plugin before using it.
I'm not sure it is appropriate but the followings patch seems to work.

diff --git a/ldap/servers/slapd/back-ldbm/init.c b/ldap/servers/slapd/back-ldbm/init.c
index 893776699..5b651595b 100644
--- a/ldap/servers/slapd/back-ldbm/init.c
+++ b/ldap/servers/slapd/back-ldbm/init.c
@@ -70,6 +70,17 @@ ldbm_back_init(Slapi_PBlock *pb)
     /* Initialize the set of instances. */
     li->li_instance_set = objset_new(&ldbm_back_instance_set_destructor);
 
+    /* initialize dblayer  */
+    if (dblayer_init(li)) {
+        slapi_log_err(SLAPI_LOG_CRIT, "ldbm_back_init", "dblayer_init failed\n");
+        goto fail;
+    }
+
+    if (bdb_init(li, NULL)) {
+        slapi_log_err(SLAPI_LOG_CRIT, "ldbm_back_init", "bdb_init failed\n");
+        goto fail;
+    }
+
     /* ask the factory to give us space in the Connection object
          * (only bulk import uses this)
          */

Package Version and Platform

21f2a06
Fedora 31

Steps to reproduce

ns-slapd dbverify -D configdir

Actual results

ns-slapd dbverify fails with segfault.

Expected results

ns-slapd dbverify exits normally.

@389-ds-bot 389-ds-bot added the closed: duplicate Migration flag - Issue label Sep 13, 2020
@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-11-12 01:19:26

I see nothing obviously wrong with the patch, what do you think @mreynolds389

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-11-12 01:19:27

Metadata Update from @Firstyear:

  • Custom field origin adjusted to None
  • Custom field reviewstatus adjusted to None

@389-ds-bot
Copy link
Author

Comment from lkrispen (@elkris) at 2019-11-12 09:21:54

It is correct that the init is missing, but dblayer_init is called in dblayer_setup, which then also decides if to call bdb_init or the init for another backend implementation.

I have fixed the crash in dbverify along with others in PR50671 which is waiting for review quite a while

@389-ds-bot
Copy link
Author

Comment from firstyear (@Firstyear) at 2019-11-12 23:56:57

Reviewing now, I think maybe I missed a review email on 389-devel then as I try to stay on top of these :)

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2019-11-14 17:50:54

Duplicate of 50659 (which is now fixed)

@389-ds-bot
Copy link
Author

Comment from mreynolds (@mreynolds389) at 2019-11-14 17:50:55

Metadata Update from @mreynolds389:

  • Issue close_status updated to: duplicate
  • Issue status updated to: Closed (was: Open)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: duplicate Migration flag - Issue
Projects
None yet
Development

No branches or pull requests

1 participant