Skip to content

Commit

Permalink
Depsgraph: Fix crash using --debug-depsgraph and --debug-depsgraph-no…
Browse files Browse the repository at this point in the history
…-threads

Was accessing past the array boundaries.

Should be safe for 2.79a.
  • Loading branch information
sergeyvfx committed Feb 21, 2018
1 parent 09aaee5 commit 9e70780
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/blender/blenkernel/intern/scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,8 @@ typedef struct ThreadedObjectUpdateState {
bool has_mballs;
#endif

int num_threads;

/* Execution statistics */
bool has_updated_objects;
ListBase *statistics;
Expand Down Expand Up @@ -1555,7 +1557,6 @@ static void scene_update_object_add_task(void *node, void *user_data)

static void print_threads_statistics(ThreadedObjectUpdateState *state)
{
int i, tot_thread;
double finish_time;

if ((G.debug & G_DEBUG_DEPSGRAPH) == 0) {
Expand Down Expand Up @@ -1583,10 +1584,9 @@ static void print_threads_statistics(ThreadedObjectUpdateState *state)
}
#else
finish_time = PIL_check_seconds_timer();
tot_thread = BLI_system_thread_count();
int total_objects = 0;

for (i = 0; i < tot_thread; i++) {
for (int i = 0; i < state->num_threads; i++) {
int thread_total_objects = 0;
double thread_total_time = 0.0;
StatisicsEntry *entry;
Expand Down Expand Up @@ -1683,6 +1683,7 @@ static void scene_update_objects(EvaluationContext *eval_ctx, Main *bmain, Scene
"scene update objects stats");
state.has_updated_objects = false;
state.base_time = PIL_check_seconds_timer();
state.num_threads = tot_thread;
}

#ifdef MBALL_SINGLETHREAD_HACK
Expand Down

0 comments on commit 9e70780

Please sign in to comment.