From 9591b5f6182f754dc06e1aff43d6b8b675aa9bf4 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 19 Sep 2017 13:57:46 +0200 Subject: Fix T52816: regression can't open file in 2.79 (crash). Tentative fix, since I cannot reproduce thenissue for some reason here on linux. Core of the problem is pretty clear though, thanks to Germano Cavalcante (@mano-wii): another thread could try to use looptris data after worker one had allocated it, but before it had actually computed looptris. So now, we use a temp 'wip' pointer to store looptris being computed (since this is protected by a mutex, other threads will have to wait on it, no possibility for them to double-compute the looptris here). This should probably be backported to 2.79a if done. --- source/blender/blenkernel/intern/subsurf_ccg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/subsurf_ccg.c') diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index ff0682258c6..ee1f5dc6696 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -4482,8 +4482,9 @@ static void ccgDM_recalcLoopTri(DerivedMesh *dm) int i, poly_index; DM_ensure_looptri_data(dm); - mlooptri = dm->looptris.array; + mlooptri = dm->looptris.array_wip; + BLI_assert(mlooptri != NULL); BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num); BLI_assert(tottri == dm->looptris.num); @@ -4502,6 +4503,9 @@ static void ccgDM_recalcLoopTri(DerivedMesh *dm) lt->tri[2] = (poly_index * 4) + 2; lt->poly = poly_index; } + + BLI_assert(dm->looptris.array == NULL); + SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip); } static void ccgDM_calcNormals(DerivedMesh *dm) -- cgit v1.2.3