Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2016-09-05 15:50:12 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2016-09-05 15:50:12 +0300
commita31eca3fdd0d2e18b73f180b87a4c77ac5a8da78 (patch)
tree4278934005fd85f74b7875a62459906c4dd64d91
parentc51cfbbc7f7be9b58f3354e0efe19aa488d984a9 (diff)
Fix T49251: moving smoke domain with additional resolution causes crash.
This is a bug in the multithreaded task manager in negative value range. The problem here is that if previter is unsigned, the comparison in the return statement is unsigned, and works incorrectly if stop < 0 && iter >= 0. This in turn can happen if stop is close to 0, because this code is designed to overrun the stop by chunk_size*num_threads as the threads terminate. This probably should go into 2.78 as it prevents a crash.
-rw-r--r--source/blender/blenlib/intern/task.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index bd7b7f9cdbd..9d4d40e1eae 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -780,9 +780,10 @@ BLI_INLINE bool parallel_range_next_iter_get(
ParallelRangeState * __restrict state,
int * __restrict iter, int * __restrict count)
{
- uint32_t previter = atomic_fetch_and_add_uint32((uint32_t *)(&state->iter), state->chunk_size);
+ uint32_t uval = atomic_fetch_and_add_uint32((uint32_t *)(&state->iter), state->chunk_size);
+ int previter = *(int32_t*)&uval;
- *iter = (int)previter;
+ *iter = previter;
*count = max_ii(0, min_ii(state->chunk_size, state->stop - previter));
return (previter < state->stop);