[vtkusers] help! wierd pthread error..?

Brad King brad.king at kitware.com
Thu May 27 15:22:38 EDT 2004


Louis Desjardins wrote:
> 
>> All threaded filters use the vtkMultiThreader, which is quite well 
>> tested.  The code uses pthread_join in all cases to cleanup threads. 
>> What OS version are you using?  What is the version of the pthread 
>> library?
> 
> 
> Okay I'm using Linux Redhat 9 , and how can I know what version of the 
> pthread library is? =S

You are probably using the Native Posix Thread Library (nptl) instead of 
the old pthreads library.  There may be a bug in this library that 
prevents programs from creating/destroying too many threads.  Please try 
running this test program by hand:

#include <stdio.h>
#include <string.h>
#include <pthread.h>

void* mythread(void* x) { pthread_exit(x); }
int main()
{
   int count = 0;
   while(1)
     {
     pthread_t tid;
     int r;
     if((r = pthread_create(&tid, 0, mythread, 0)) == 0)
       { void* ret; pthread_join(tid, &ret); }
     else
       { fprintf(stderr, "%s\n", strerror(r)); return 1; }
     if(++count % 1000 == 0)
       { printf("Finished %d threads.\n", count); }
     }
   return 0;
}

Compile it like this:

gcc thread1.c -lpthreads

It should run forever printing out a message for every 1000 threads 
created and destroyed.  If this fails on your system then we have found 
the problem.  Please let me know either way.

> Someone else said my problem is that I am not deleting objects after 
> using them? But I need all my objects i.e. all my filters and sources 
> and datasets etc because they are all used to render my scene
> What do you think?

I do not think this is the case.  The threaded filters do not keep the 
threads running unless they are executing, so not deleting them would 
not hold extra threads open.

-Brad



More information about the vtkusers mailing list