Full_Name: wondersoft Version: 2.4.39 OS: CentOS 6.6 X86_64 URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (182.50.119.36) Hi: My server is CentOS 6.6(x86_64). When I create a thread on the main(), it's failed on ldap_init(), but it's ok at main not running on a sub thread. But using the same version and the same code, it runs pretty well at CentOS 6.6(x86_32). Test code is here: void pthread_ldap() { LDAP *ld = NULL; ld=(LDAP*)ldap_init(HOSTNAME,0); if(ld ==NULL) { perror("ldap_init"); return ; } int protocolVersion = LDAP_VERSION3; //It failed here, if ituns s on CentOS 6.6(x86_64) as a sub thread. ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &(protocolVersion)); return ; } int main() { int ret = 0; pthread_attr_t attr_attribute; pthread_attr_init(&attr_attribute); pthread_attr_setdetachstate(&attr_attribute,PTHREAD_CREATE_DETACHED); pthread_t pid; //If no sub thread created, it's ok //pthread_ldap(); if( pthread_create( &pid, &attr_attribute, (void*)pthread_ldap, NULL ) ) { perror(" Create pthread_ldap ERROR"); } } gdb chasing result: (gdb) 222 rc = ldap_set_option(ld, LDAP_OPT_HOST_NAME, defhost); (gdb) 223 if ( rc != LDAP_SUCCESS ) { (gdb) p ld $6 = (LDAP *) 0x7ffff00008c0 (gdb) pthread_ldap () at OPENLDAP_exam.c8686 186 printf("ldap_init ld = %d\n", ld); (gdb) p ld $7 = (LDAP *) 0xfffffffff00008c0 gcc version: gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. OS version: Linux localhost.localdomain 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux gcc command: gcc OPENLDAP_exam.c -g -o OPENLDAP_exam -L/usr/local/lib -lldap -llber -lpthread
moved from Incoming to Software Bugs
Can you reproduce this with the OpenLDAP 2.5 alpha?