Buenas. Les comento el error que tengo. Yo tengo un thread Server, que recibe Clientes (Threads), procesa sus solicitudes y manda respuesta a cada uno. Cada vez que entra un cliente, creo un nuevo thread llamado ClientHandler, haciendo un new. Luego, lo agrego a un Vector de ClientHandlers, que es static, y pertenece a la clase Server. En el caso de que introduzca 3 o menos clienthandlers, cuando el server termina (no recibe mas clientes), el programa cierra correctamente. En el caso de recibir 4 o mas clientes, el programa pincha justo en el join del thread server.
[EMAIL PROTECTED]:~/Taller/TP4$ valgrind --leak-check=full ./server 10091 4 ==15175== Memcheck, a memory error detector. ==15175== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al. ==15175== Using LibVEX rev 1471, a library for dynamic binary translation. ==15175== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP. ==15175== Using valgrind-3.1.0-Debian, a dynamic binary instrumentation framework. ==15175== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al. ==15175== For more details, rerun with: -v ==15175== Ingreso un cliente! Ingreso un cliente! Ingreso un cliente! Ingreso un cliente! Ultima linea del main del Server! Cliente 1 Hice el stop! Hice el join! Borre un Thread! Hice el Borrado! Cliente 2 Hice el stop! Hice el join! Borre un Thread! Hice el Borrado! Cliente 3 Hice el stop! Hice el join! Borre un Thread! Hice el Borrado! Cliente 4 Hice el stop! Hice el join! Borre un Thread! Hice el Borrado! Vaciado OK de ClientHandlers! Fin del destructor del Server! ==15175== Invalid read of size 4 ==15175== at 0x4B24FDB: pthread_join (in /lib/libpthread-2.3.6.so) ==15175== by 0x405C6F: Thread::~Thread() (in /home/naspab/Taller/TP4/server) ==15175== by 0x403AE3: Server::~Server() (in /home/naspab/Taller/TP4/server) ==15175== by 0x40311E: main (in /home/naspab/Taller/TP4/server) ==15175== Address 0x5BFB9F0 is not stack'd, malloc'd or (recently) free'd ==15175== ==15175== Process terminating with default action of signal 11 (SIGSEGV) ==15175== Access not within mapped region at address 0x5BFB9F0 ==15175== at 0x4B24FDB: pthread_join (in /lib/libpthread-2.3.6.so) ==15175== by 0x405C6F: Thread::~Thread() (in /home/naspab/Taller/TP4/server) ==15175== by 0x403AE3: Server::~Server() (in /home/naspab/Taller/TP4/server) ==15175== by 0x40311E: main (in /home/naspab/Taller/TP4/server) ==15175== ==15175== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 8 from 1) ==15175== malloc/free: in use at exit: 2,187 bytes in 25 blocks. ==15175== malloc/free: 164 allocs, 139 frees, 5,287 bytes allocated. ==15175== For counts of detected errors, rerun with: -v ==15175== searching for pointers to 25 not-freed blocks. ==15175== checked 33,846,712 bytes. ==15175== ==15175== ==15175== 507 bytes in 18 blocks are possibly lost in loss record 3 of 5 ==15175== at 0x4A19DE3: operator new(unsigned long) (vg_replace_malloc.c:168) ==15175== by 0x4CCBC7C: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.7) ==15175== by 0x4CCC07B: (within /usr/lib/libstdc++.so.6.0.7) ==15175== by 0x4CCC211: std::string::string(char const*, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.7) ==15175== by 0x403ED2: __static_initialization_and_destruction_0(int, int) (in /home/naspab/Taller/TP4/server) ==15175== by 0x406C01: (within /home/naspab/Taller/TP4/server) ==15175== by 0x4018F2: (within /home/naspab/Taller/TP4/server) ==15175== ==15175== ==15175== 544 bytes in 4 blocks are possibly lost in loss record 4 of 5 ==15175== at 0x4A1AD7D: calloc (vg_replace_malloc.c:279) ==15175== by 0x400DCA8: _dl_allocate_tls (in /lib/ld-2.3.6.so) ==15175== by 0x4B246B8: pthread_create@@GLIBC_2.2.5 (in /lib/libpthread-2.3.6.so) ==15175== by 0x405DC6: Thread::run() (in /home/naspab/Taller/TP4/server) ==15175== by 0x403D3A: Server::main() (in /home/naspab/Taller/TP4/server) ==15175== by 0x405CA9: Thread::static_run(void*) (in /home/naspab/Taller/TP4/server) ==15175== by 0x4B240F9: start_thread (in /lib/libpthread-2.3.6.so) ==15175== by 0x5189CE1: clone (in /lib/libc-2.3.6.so) ==15175== ==15175== LEAK SUMMARY: ==15175== definitely lost: 0 bytes in 0 blocks. ==15175== possibly lost: 1,051 bytes in 22 blocks. ==15175== still reachable: 1,136 bytes in 3 blocks. ==15175== suppressed: 0 bytes in 0 blocks. ==15175== Reachable blocks (those to which a pointer was found) are not shown. ==15175== To see them, rerun with: --show-reachable=yes Fallo de segmentación ------------------------------------ El tema es que no entiendo la diferencia que hay en que entren 3, 5 o 100 clientes. Si la ejecucion con 3 clientes en paralelo funciona perfectamente, entonces, si entran 5, deberia ir bien igual. Lo raro ademas es que si entran 10 clientes, los trata bien el server, aceptando sus solicitudes, y mandando respuestas adecuadas a todos los clientes. Luego los borra del vector de clientHandlers, y ni bien termina la ultima linea del destructor del Server, cuando llama al destructor de thread ( lo unico que hace es un join() ), entonces ahi pincha. Si alguien tiene alguna idea de donde esta el error, por favor, aviseme! Muchas gracias! Pablo Statile _______________________________________________ Lista de correo Programacion. [email protected] http://listas.fi.uba.ar/mailman/listinfo/programacion
