I have code on two systems running kernel 2.4.20
and kernel 2.4.38
. Both have gcc 3.2.2
and glibc 2.3.2
In kernel 2.4.38
pthread_t handles are not reused. In a heavy load test, the application crashes after the handles reach 0xFFFFFFFF
.
(I suspected this in the first place, because the application crashes in deployments where IT uses a network port scanner - threads are created to handle socket connections)
This simple example recreates the problem:
void* ThreadProc(void* param) { usleep(10000); printf(" Thread 0x%x\n", (unsigned int)pthread_self()); usleep(10000); return NULL; } int main(int argc, char* argv[]) { pthread_t sThread; while(1) { pthread_create(&sThread, NULL, ThreadProc, NULL); printf("Created 0x%x\n", (unsigned int)sThread); pthread_join(sThread, NULL); }; return 0; }
In section 2.4.20:
Created 0x40838cc0 Thread 0x40838cc0 Created 0x40838cc0 Thread 0x40838cc0 Created 0x40838cc0 Thread 0x40838cc0 ...and on and on...
In section 2.4.36:
Created 0x4002 Thread 0x4002 Created 0x8002 Thread 0x8002 Created 0xc002 Thread 0xc002 ...keeps growing...
How can I get kernel 2.4.36
to handle descriptors? Unfortunately, I cannot easily change the kernel. Thanks!
Scott source share