Commit 8f6b3cbb authored by Min Si's avatar Min Si Committed by Huiwei Lu
Browse files

A workaround for FreeBSD pthread mallc/free bug.



On FreeBSD, test threads/pt2pt/multisend4 sometimes reports the segfault
error when calling free function. This error only happens when the
buffer size is equal to 4M bytes and every thread performs malloc/free
for multiple times. This bug can be reproduced by using simple memcpy
without MPI communication, thus it is considered not as a MPI bug but a
bug of the thread-safe memory allocation on FreeBSD. A workaround of
this bug is to move malloc-free outside the loop to avoid frequent
malloc-free calls. This patch added it.
Signed-off-by: default avatarHuiwei Lu <huiweilu@mcs.anl.gov>
parent a5682675
......@@ -44,9 +44,9 @@ MTEST_THREAD_RETURN_TYPE run_test_sendrecv(void *arg)
fprintf( stderr, "Panic wsize = %d nthreads = %d\n",
wsize, nthreads );
for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
buf = (int *)malloc( 2*cnt * sizeof(int) );
buf = (int *) malloc(2 * MAX_CNT * sizeof(int));
for (cnt=1; cnt < MAX_CNT; cnt = 2*cnt) {
/* Wait for all senders to be ready */
MTest_thread_barrier(nthreads);
......@@ -72,10 +72,11 @@ MTEST_THREAD_RETURN_TYPE run_test_sendrecv(void *arg)
t = MPI_Wtime() - t;
/* can't free the buffers until the requests are completed */
MTest_thread_barrier(nthreads);
free( buf );
if (thread_num == 1)
MTestPrintfMsg( 1, "buf size %d: time %f\n", cnt, t / MAX_LOOP );
}
free(buf);
return (MTEST_THREAD_RETURN_TYPE)NULL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment