Index: openmp/runtime/src/kmp_tasking.cpp =================================================================== --- openmp/runtime/src/kmp_tasking.cpp +++ openmp/runtime/src/kmp_tasking.cpp @@ -298,6 +298,7 @@ static void __kmp_realloc_task_deque(kmp_info_t *thread, kmp_thread_data_t *thread_data) { kmp_int32 size = TASK_DEQUE_SIZE(thread_data->td); + KMP_DEBUG_ASSERT(TCR_4(thread_data->td.td_deque_ntasks) == size); kmp_int32 new_size = 2 * size; KE_TRACE(10, ("__kmp_realloc_task_deque: T#%d reallocating deque[from %d to " @@ -382,7 +383,10 @@ __kmp_acquire_bootstrap_lock(&thread_data->td.td_deque_lock); locked = 1; // expand deque to push the task which is not allowed to execute - __kmp_realloc_task_deque(thread, thread_data); + if (TCR_4(thread_data->td.td_deque_ntasks) >= + TASK_DEQUE_SIZE(thread_data->td)) { + __kmp_realloc_task_deque(thread, thread_data); + } } } // Lock the deque for the task push operation