pthread-related crashes
Hi all,
I'm running ROS electric on a 24-core machine and having some issues with pthread under specific conditions. I use a class named ObjectTracker to handle ROS callbacks and sometimes use pthread to run some code in parallel without a problem. However, ObjectTracker includes instances of another class called Model, and Model includes functions that use pthread, as well. When Model tries to use pthread, the code usually crashes. I've tried using spin, multithreadspinner, and asyncspinner in ObjectTracker, and I still get the crashes. I'm also not trying to use more than 24 cores when it crashes. Even if I'm only trying to use on thread, but as long as it's created with pthread within Model and not ObjectTracker, it's a problem. Here's the specific code that is problematic:
// create threads
pthread_attr_t attr;
int rc;
void* status;
int count_thread = 0;
while(count_thread<num_threads)
{
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
for(int i=count_thread;i<min(count_thread+simultaneous_threads,num_threads);i++)
{
pthread_create(&threads[i], &attr, thread_align_cloud_init, (void *) &aligndata[i]);
}
// wait for the threads to execute
pthread_attr_destroy(&attr);
for(int i=count_thread;i<min(count_thread+simultaneous_threads,num_threads);i++)
rc = pthread_join(threads[i], &status);
count_thread+=simultaneous_threads;
}
Any help would be appreciated!!