I was able to reproduce this problem again. It does not happen during every run of test039-glue-ldap-concurrency (probably during 1 out of 10). This time I had enabled debug logging in the slapd-search tester. Find the log of it below. What's really strange that it fails when chasing a referral to ldap://localhost:9016 (there is nothing listening on port 9016 during test039)
[..] ldap_chase_v3referral: msgid 374, url "ldap://localhost:9016/cn=Somewhere,ou=Meta,dc=example,dc=com??sub" ldap_send_server_request ldap_new_connection 0 1 1 ldap_int_open_connection ldap_connect_to_host: TCP localhost:9016 ldap_new_socket: 4 ldap_prepare_socket: 4 ldap_connect_to_host: Trying 127.0.0.1:9016 ldap_connect_timeout: fd: 4 tm: -1 async: 0 anonymous rebind via ldap_bind_s ldap_sasl_bind ldap_send_initial_request ldap_send_server_request ldap_result ld 0x100141e0 msgid 376 ldap_chkResponseList ld 0x100141e0 msgid 376 all 1 ldap_chkResponseList returns ld 0x100141e0 NULL wait4msg ld 0x100141e0 msgid 376 (timeout 100000 usec) wait4msg continue ld 0x100141e0 msgid 376 all 1 ** ld 0x100141e0 Connections: * host: localhost port: 9016 refcnt: 2 status: Connected last used: Thu Apr 12 08:10:47 2007 rebind in progress queue is empty
* host: localhost port: 9013 (default) refcnt: 2 status: Connected last used: Thu Apr 12 08:10:47 2007
** ld 0x100141e0 Outstanding Requests: * msgid 376, origid 376, status InProgress outstanding referrals 0, parent count 0 * msgid 374, origid 374, status InProgress outstanding referrals 1, parent count 0 ** ld 0x100141e0 Response Queue: * msgid 374, type 100 ldap_chkResponseList ld 0x100141e0 msgid 376 all 1 ldap_chkResponseList returns ld 0x100141e0 NULL ldap_int_select read1msg: ld 0x100141e0 msgid 376 all 1 read1msg: ld 0x100141e0 msgid 376 message type unknown new result: res_errno: 3, res_error: <>, res_matched: <> read1msg: ld 0x100141e0 0 new referrals read1msg: mark request completed, ld 0x100141e0 msgid 376 request done: ld 0x100141e0 msgid 376 res_errno: 3, res_error: <>, res_matched: <> ldap_free_request (origid 376, msgid 376) ldap_free_connection 0 1 ldap_free_connection: refcnt 1 ldap_new_connection 0x100141e0: unexpected response 96 from BIND request id=376 lt-slapd-search: request.c:470: ldap_new_connection: Assertion `0' failed. [..]