I have a wrapper manager code on top of openldap stack(ver.2.4.11), there manager code is responsible for creating the ldap connecting to the LDAP servers by using the standard ldap API().

u32_t rc=ldap_sasl_bind(ld, loginDN, LDAP_SASL_SIMPLE, &cred, NULL, NULL, &msgid); //asynchronous bind

 if (rc != LDAP_SUCCESS )
 {
  ldapErrorLog(":connect: LDAP Bind send Failed:%s \n ", ldap_err2string(rc));
  ldap_unbind_ext_s(ld, NULL,NULL);
  m_connInitialized = false;
  return(LDAPRC_FAIL);
 }

return LDAPRC_SUCCESS;

by using this wrapper code I am creating many ldap links ,most of time this is working fine some times when the ldap_sasl_bind() returns -1 (can't contact server) or unknown error the code is crashing in ldap_unbind_ext_s. can anyone help out.

the log and gdb trace are pasted below

(gdb) bt
#0  ldap_free_request (ld=0x16fd370, lr=0x1010001020001) at request.c:866
#1  0x00000000005372e8 in ldap_ld_free (ld=0x16fd370, close=1, sctrls=<value optimized out>, cctrls=<value optimized out>) at unbind.c:88
#2  0x000000000044b020 in LdapConnection::connect (this=0x157bcd0, loginDN=0x157b3ec "cn=TASuser", pwd=<value optimized out>)

logs..

<18:06:56.414 **ERR** LDAP 22603:22470 3:0><LdapConnection.cpp(171)>:connect: LDAP Bind send Failed:Can't contact LDAP server
 <18:06:56.414 *WRN* MX 22603:22470 3:0>receive SEGV signal
<18:06:56.414 *WRN* MX 22603:22470 3:0>Message dump is disabl


Regards,
Sachin Vastrad