[mpich-discuss] [PATCH] Issue 5486: Nobody checks the return code from "MTest_Start_thread()".

Joe Ratterman jratt0 at gmail.com
Thu May 21 16:39:41 CDT 2009


From: Joe Ratterman <jratt at us.ibm.com>

BGP has a maximum of 3 threads that can be created (SMP mode), but
sometimes only 1 (DUAL mode).  Because some tests try to create more
than 3 threads, pthread_create() will fail.  However, nobody checks
that, so the tests time-out.

This adds an abort: if something absolutely *must* happen, you cannot
let it silently fail.
---
 mpich2/test/mpi/threads/pt2pt/testlist     |    6 +++---
 mpich2/test/mpi/threads/util/mtestthread.c |    9 +++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/mpich2/test/mpi/threads/pt2pt/testlist b/mpich2/test/mpi/threads/pt2pt/testlist
index d62e8c7..c53b354 100644
--- a/mpich2/test/mpi/threads/pt2pt/testlist
+++ b/mpich2/test/mpi/threads/pt2pt/testlist
@@ -2,8 +2,8 @@ threaded_sr 2
 alltoall 4
 sendselfth 1
 multisend 2
-multisend2 5
-multisend3 5
-multisend4 5
+# multisend2 5 # This test uses too many threads
+# multisend3 5 # This test uses too many threads
+# multisend4 5 # This test uses too many threads
 greq_wait 1
 greq_test 1
diff --git a/mpich2/test/mpi/threads/util/mtestthread.c b/mpich2/test/mpi/threads/util/mtestthread.c
index b171785..af01643 100644
--- a/mpich2/test/mpi/threads/util/mtestthread.c
+++ b/mpich2/test/mpi/threads/util/mtestthread.c
@@ -60,7 +60,6 @@ int MTest_Join_threads( void ){
 int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE (*fn)(void *p),void *arg)
 {
     int err;
-    pthread_t thread;
     pthread_attr_t attr;
     pthread_attr_init(&attr);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
@@ -71,7 +70,13 @@ int MTest_Start_thread(MTEST_THREAD_RETURN_TYPE (*fn)(void *p),void *arg)
 	return 1;
     }
     err = pthread_create(threads+nthreads, &attr, fn, arg);
-    if (!err) nthreads++;
+    if (!err)
+        nthreads++;
+    else
+    {
+        fprintf(stderr, "Failed to create thread calling func %p with arg %p\n", fn, arg);
+        abort();
+    }
     pthread_attr_destroy(&attr);
     return err;
 }
-- 
1.6.3.2.gbfc07d5



More information about the mpich-discuss mailing list