[Date Prev][Date Next] [Chronological] [Thread] [Top]

Segmentation fault with a lot of Bind/unbind




With le lastest version of openLDAP 1 (1.2.13), I get a Segmentation fault when stressing out the server with clients make a bind/unbind for few request.
I use the slapd server with our own backend.


I have launch 6 clients per 2 seconds, each client make 1 bind, 2request (60 ms between each request), 1 unbind ; the total of those 4 steps is less than 2 secondes in order to have almost a maximum of 6 clients.
The Coredump appears between 5 and 10 minutes.


The increase of number of client decrease the time before the coreDump appears. For exemple, with 12 clients per 2 seconds, the coredumpt appears sometimes after only 30 seconds.

I am trying to have a lot of bind/unbind with only one client but with this configuration, slapd hasn't made yet a coredump.

In the archive of bugs, I have seen the post http://www.openldap.org/lists/openldap-bugs/199902/msg00011.html . It is perhaps the same bug.

Could it be a configuration problem of the Thread ?
Could it be a bug of openLDAP ? perhaps a concurrent acces in the bind or the unbind ?


Thank for help.

Gael LEGARGEANT
Tel : +33 (0)2 99 27 84 59
Capgemini Telecom & Media
Skill Center VASN
5 allée de la Croix des Hêtres - CS 50801
35 708 RENNES Cedex 07
FRANCE

***************************************************
Linux configuration :
***************************************************
uname -a :
Linux gtar1 2.4.21-37.ELhugemem #1 SMP Wed Sep 7 13:22:27 EDT 2005 i686 i686 i386 GNU/Linux


***************************************************
the hardware configuration :
***************************************************
Bi pro intel Xéon à 3,0 Ghz,
8 Go RAM par processeur,
6 hard disk (1 disk system et 2 disks soft  in RAID mode)

***************************************************
The Core dump:
***************************************************
[opgtagtr@gtar1]gdb slapd.exe core.11914
GNU gdb Red Hat Linux (6.3.0.0-1.62rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".


Core was generated by `./slapd.exe -f /exec/applis/gtagtr/util/conf/gtar.conf -p 3089'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /exec/products/oracle/v9.2.0/lib/libclntsh.so.9.0...done.
Loaded symbols for /exec/products/oracle/v9.2.0/lib/libclntsh.so.9.0
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/tls/libpthread.so.0...done.
Loaded symbols for /lib/tls/libpthread.so.0
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /exec/products/oracle/v9.2.0/lib/libwtc9.so...done.
Loaded symbols for /exec/products/oracle/v9.2.0/lib/libwtc9.so
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
#0 0x0013ac40 in pthread_detach () from /lib/tls/libpthread.so.0
(gdb) backtrace
#0 0x0013ac40 in pthread_detach () from /lib/tls/libpthread.so.0
#1 0x080615ee in ldap_pvt_thread_create (thread=0xf5f00730, detach=1,
start_routine=0x804b308 <connection_operation>, arg=0xf5f009b8)
at thr_posix.c:66
#2 0x0804b746 in connection_activity (conn=0xf6543180) at connection.c:252
#3 0x0804af47 in slapd_daemon (port=0x400) at daemon.c:409
#4 0x00139dd8 in start_thread () from /lib/tls/libpthread.so.0
#5 0x00221d1a in clone () from /lib/tls/libc.so.6
(gdb) up
#1 0x080615ee in ldap_pvt_thread_create (thread=0xf5f00730, detach=1,
start_routine=0x804b308 <connection_operation>, arg=0xf5f009b8)
at thr_posix.c:66
66 thr_posix.c: Aucun fichier ou répertoire de ce type.
in thr_posix.c
(gdb) print arg
$1 = (void *) 0xf5f009b8
(gdb) print 0xf5f009b8
$2 = 4126149048
(gdb) up
#2 0x0804b746 in connection_activity (conn=0xf6543180) at connection.c:252
252 connection.c: Aucun fichier ou répertoire de ce type.
in connection.c
(gdb) print conn
$3 = (Connection *) 0xf6543180
(gdb) print 0xf6543180
$4 = 4132712832




***************************************************
The source connection.c after a few modifications
***************************************************
#include "portable.h"



#include <stdio.h>



#include <ac/errno.h>

#include <ac/signal.h>

#include <ac/socket.h>

#include <ac/string.h>

#include <ac/time.h>



#include "slap.h"



struct co_arg {

     Connection      *co_conn;

     Operation      *co_op;

};



/*

* connection_activity - handle the request operation op on connection

* conn.  This routine figures out what kind of operation it is and

* calls the appropriate stub to handle it.

*/



static void *

connection_operation( void *arg_v )

{

     struct co_arg      *arg = (struct co_arg *) arg_v;

     unsigned long      len;



/* #marq_ajout# GTAR 23/11/05 - PBR - prise de temps */

#ifdef SLAPD_GTA

     struct timeval  tvDebutPeriode;

     struct timeval  tvFinPeriode;

     struct timezone tzTimeZone;

#endif

/* #marq_ajout# GTAR 23/11/05 - PBR - prise de temps */



     ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex );

     arg->co_conn->c_opsinitiated++;

     ldap_pvt_thread_mutex_unlock( &arg->co_conn->c_opsmutex );



     ldap_pvt_thread_mutex_lock( &ops_mutex );

     ops_initiated++;

     ldap_pvt_thread_mutex_unlock( &ops_mutex );



     /*struct sched_param T_SCHEDPARAM;

     T_SCHEDPARAM.sched_priority = 110;

     pthread_setschedparam( pthread_self( ), SCHED_RR, &T_SCHEDPARAM );*/



     switch ( arg->co_op->o_tag ) {

     case LDAP_REQ_BIND:

           do_bind( arg->co_conn, arg->co_op );

           break;



#ifdef LDAP_COMPAT30

     case LDAP_REQ_UNBIND_30:

#endif

     case LDAP_REQ_UNBIND:

           do_unbind( arg->co_conn, arg->co_op );

           break;



     case LDAP_REQ_ADD:

           do_add( arg->co_conn, arg->co_op );

           break;



#ifdef LDAP_COMPAT30

     case LDAP_REQ_DELETE_30:

#endif

     case LDAP_REQ_DELETE:

           do_delete( arg->co_conn, arg->co_op );

           break;



     case LDAP_REQ_MODRDN:

           do_modrdn( arg->co_conn, arg->co_op );

           break;



     case LDAP_REQ_MODIFY:

           do_modify( arg->co_conn, arg->co_op );

           break;



     case LDAP_REQ_COMPARE:

           do_compare( arg->co_conn, arg->co_op );

           break;



     case LDAP_REQ_SEARCH:



             /* #marq_ajout# GTAR 23/11/05 - PBR - prise de temps */

           #ifdef SLAPD_GTA

                 gettimeofday(&tvDebutPeriode, &tzTimeZone);

           #endif

             /* #marq_ajout# GTAR 23/11/05 - PBR - prise de temps */



           do_search( arg->co_conn, arg->co_op );



             /* #marq_ajout# GTAR 23/11/05 - PBR - prise de temps */

           #ifdef SLAPD_GTA

                 gettimeofday(&tvFinPeriode, &tzTimeZone);

         gis_maj_stats(tvDebutPeriode, tvFinPeriode);

           gis_trace_stats( );

           #endif

             /* #marq_ajout# GTAR 23/11/05 - PBR - prise de temps */



           break;



#ifdef LDAP_COMPAT30

     case LDAP_REQ_ABANDON_30:

#endif

     case LDAP_REQ_ABANDON:

           do_abandon( arg->co_conn, arg->co_op );

           break;



     default:

           Debug( LDAP_DEBUG_ANY, "unknown request 0x%lx\n",

               arg->co_op->o_tag, 0, 0 );

           break;

     }



     ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex );

     arg->co_conn->c_opscompleted++;



     slap_op_delete( &arg->co_conn->c_ops, arg->co_op );

     arg->co_op = NULL;



     ldap_pvt_thread_mutex_unlock( &arg->co_conn->c_opsmutex );



     arg->co_conn = NULL;

     free( (char *) arg );



     ldap_pvt_thread_mutex_lock( &ops_mutex );

     ops_completed++;

     ldap_pvt_thread_mutex_unlock( &ops_mutex );



     ldap_pvt_thread_mutex_lock( &active_threads_mutex );

     active_threads--;

     if( active_threads < 1 ) {

           ldap_pvt_thread_cond_signal(&active_threads_cond);

     }

     ldap_pvt_thread_mutex_unlock( &active_threads_mutex );



     return NULL;

}



void

connection_activity(

   Connection *conn

)

{

     int status;

     struct co_arg      *arg;

     unsigned long      tag, len;

     long        msgid;

     BerElement  *ber;

     char        *tmpdn;



     if ( conn->c_currentber == NULL && (conn->c_currentber = ber_alloc())

         == NULL ) {

           Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );

           return;

     }



     errno = 0;

     if ( (tag = ber_get_next( &conn->c_sb, &len, conn->c_currentber ))

         != LDAP_TAG_MESSAGE ) {

           int err = errno;

           Debug( LDAP_DEBUG_TRACE,

               "ber_get_next on fd %d failed errno %d (%s)\n",

               conn->c_sb.sb_sd, err, err > -1 && err < sys_nerr ?

               sys_errlist[err] : "unknown" );

           Debug( LDAP_DEBUG_TRACE, "*** got %ld of %lu so far\n",

(long)(conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf),

               conn->c_currentber->ber_len, 0 );



           if ( err != EWOULDBLOCK && err != EAGAIN ) {

                 /* log, close and send error */

                 ber_free( conn->c_currentber, 1 );

                 conn->c_currentber = NULL;



                 close_connection( conn, conn->c_connid, -1 );

           }



           return;

     }

     ber = conn->c_currentber;

     conn->c_currentber = NULL;



     if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) {

           /* log, close and send error */

           Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,

               0 );

           ber_free( ber, 1 );



           close_connection( conn, conn->c_connid, -1 );

           return;

     }



     if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {

           /* log, close and send error */

           Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,

               0 );

           ber_free( ber, 1 );



           close_connection( conn, conn->c_connid, -1 );

           return;

     }



#ifdef LDAP_COMPAT30

     if ( conn->c_version == 30 ) {

           (void) ber_skip_tag( ber, &len );

     }

#endif



     arg = (struct co_arg *) ch_malloc( sizeof(struct co_arg) );

     arg->co_conn = conn;



     ldap_pvt_thread_mutex_lock( &conn->c_dnmutex );

     if ( conn->c_dn != NULL ) {

           tmpdn = ch_strdup( conn->c_dn );

     } else {

           tmpdn = NULL;

     }

     ldap_pvt_thread_mutex_unlock( &conn->c_dnmutex );



     ldap_pvt_thread_mutex_lock( &conn->c_opsmutex );

     arg->co_op = slap_op_add( &conn->c_ops, ber, msgid, tag, tmpdn,

         conn->c_opsinitiated, conn->c_connid );

     ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex );



     if ( tmpdn != NULL ) {

           free( tmpdn );

     }



/* #marq_ajout# G01R00C02 - GTAR 14/04/06 - PBR - vérification du nombre de thread */

     char pchLog[200];

     ldap_pvt_thread_mutex_lock( &active_threads_mutex );

           if (active_threads > 150) {

                 sprintf(pchLog,

"Le nombre de threads actifs au niveau du serveur LDAP est supérieur à 150 : %d threads actifs",

                             active_threads);

                 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );

                 gl_ecrire_log(pchLog);

ga_ecrire_alarme ("WARN", "SLAPD", "Nombre de threads maximum depasse", 53);

                 send_ldap_result( conn, arg->co_op, LDAP_BUSY, NULL,

                       "Number of threads exceeded" );

                 goto return_results;

           } else {

                 active_threads++;

                 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );

           }



/* #marq_ajout# G01R00C02 - GTAR 14/04/06 - PBR - vérification du nombre de thread */



--------Line 252-----

     if ( status = ldap_pvt_thread_create( &arg->co_op->o_tid, 1,

         connection_operation, (void *) arg ) != 0 ) {

Debug( LDAP_DEBUG_ANY, "ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );

     }



/* #marq_ajout# G01R00C02 - GTAR 14/04/06 - PBR - vérification du nombre de thread */

     return_results:;

/* #marq_ajout# G01R00C02 - GTAR 14/04/06 - PBR - vérification du nombre de thread */



}





This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.