__kmp_realloc_task_deque implicitly assumes, that the task queue is full (ntasks == size), therefore tail = size in line 319.
I added an assertion to document this assumption.
The first check for a full queue is before the locking and might not hold when the lock is taken. So, we need to check again for this condition when we have the lock.
This fixes the issue for the simple reproducer provided by Raul on openmp-dev, but also my issue with a more complex code.
Move comment under the if.