From c626462c0fe1257c07948b49db1a41526682ba3f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 21 Mar 2014 13:44:38 +0100 Subject: Fix T39209: Localizing materials could cause heisenbug with concurrent depsgraph updates. Material datablocks were localized by first making a regular datablock copy, which always gets inserted into the bmain list, and then removing it again from bmain. Problem is that this localization happens in preview threads, which can run while the depsgraph is also updating GPU materials. In case the copying of materials takes any amount of time, this can cause the depsgraph call to material_changed to use an invalid, localized material and access invalid GPUMaterial lists which have already been freed for the actual material. Solution is to not add localized datablocks to the bmain lists in the first place. bmain should be totally immutable during preview or render threads. --- source/blender/blenkernel/intern/material.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/material.c') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 0dd62ae730d..eb8b385bbc7 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -256,8 +256,7 @@ Material *localize_material(Material *ma) Material *man; int a; - man = BKE_libblock_copy(&ma->id); - BLI_remlink(&G.main->mat, man); + man = BKE_libblock_copy_nolib(&ma->id); /* no increment for texture ID users, in previewrender.c it prevents decrement */ for (a = 0; a < MAX_MTEX; a++) { -- cgit v1.2.3