Page MenuHome

regression can't open file in 2.79 (crash)
Closed, ResolvedPublic


System Information
Windows x64

Blender Version
Broken: 2.79
Worked: 2.74 to 2.78

Short description of error
Some files get an instant crash when trying to open in 2.79

Exact steps for others to reproduce the error
Try to open this file saved with 2.74

Event Timeline

Cannot confirm that here on linux64, with a debug build of current master… can you check if you still get crash with the latest build from our buildbot?

Bastien Montagne (mont29) triaged this task as Needs Information from User priority.Sep 18 2017, 8:01 PM

I can repro when i enable the page heap on windows ( don't have time to extract a stackdump now sadly) so i'm pretty sure asan will catch this on linux as well.

LazyDodo (LazyDodo) raised the priority of this task from Needs Information from User to Confirmed, Medium.Sep 18 2017, 9:19 PM

allright had some time, here's a stackdump

>	blender.exe!bvhtree_from_mesh_looptri_create_tree(float epsilon, int tree_type, int axis, const MVert * vert, const MLoop * mloop, const MLoopTri * looptri, const int looptri_num, const unsigned int * looptri_mask, int looptri_num_active) Line 1028	C
 	blender.exe!bvhtree_from_mesh_looptri(BVHTreeFromMesh * data, DerivedMesh * dm, float epsilon, int tree_type, int axis) Line 1171	C
 	blender.exe!shrinkwrap_get_tarmat(bConstraint * con, bConstraintOb * cob, bConstraintTarget * ct, float UNUSED_ctime) Line 3562	C
 	blender.exe!BKE_constraint_targets_for_solving_get(bConstraint * con, bConstraintOb * cob, ListBase * targets, float ctime) Line 4952	C
 	blender.exe!BKE_constraints_solve(ListBase * conlist, bConstraintOb * cob, float ctime) Line 5007	C
 	blender.exe!BKE_object_where_is_calc_time_ex(Scene * scene, Object * ob, float ctime, RigidBodyWorld * rbw, float[3] * r_originmat) Line 2100	C
 	blender.exe!BKE_object_where_is_calc_ex(Scene * scene, RigidBodyWorld * rbw, Object * ob, float[3] * r_originmat) Line 2138	C
 	blender.exe!BKE_object_handle_update_ex(EvaluationContext * eval_ctx, Scene * scene, Object * ob, RigidBodyWorld * rbw, const bool do_proxy_update) Line 2649	C
 	blender.exe!scene_update_object_func(TaskPool * pool, void * taskdata, int threadid) Line 1620	C
 	blender.exe!task_scheduler_thread_run(void * thread_p) Line 441	C

looptri[i] is pointing to uninitialized ram.

This smells like threading issues again, pretty sure running with -t 1 option is enough to get rid of the crash?

Will check on this more tomorrow, but could not reproduce the issue even with an debug/asan build here with master code.

Stack dump is from latest master, can confirm -t 1 gets rid of the crash.

I made a weird change in the code that seems to solve the problem:

diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index ed10f905539..27c985a8306 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1919,12 +1919,16 @@ void CDDM_recalc_looptri(DerivedMesh *dm)
 	const unsigned int totloop = dm->numLoopData;
+	struct MLoopTri *array = dm->looptris.array;
+	dm->looptris.array = NULL;
 	        cddm->mloop, cddm->mpoly,
 	        totloop, totpoly,
-	        cddm->dm.looptris.array);
+	        array);
+	dm->looptris.array = array;
 static void cdDM_free_internal(CDDerivedMesh *cddm)

Apparently, since the condition: "if (dm->looptris.array) {" of the dm_getLoopTriArray function is out of the thread's mutex_lock, the dm->looptris.array can be used before being "fully written".

My solution was to leave dm->looptris.array NULL during the entire process of creating the looptris array.
(if I avoided malloc within DM_ensure_looptri_data would be more correct)

Uh… good point didn’t thought about that kind of concurrency issue :P

Will try to find more generic way to do that (including other DM types), but that's clearly the way to go indeed.

Note that rB9591b5f6182f is tentative fix (based on @Germano Cavalcante (mano-wii)'s work), if one of you guys could confirm it fixes the issue would be great. ;)

Note that rB9591b5f6182f is tentative fix (based on @Germano Cavalcante (mano-wii)'s work), if one of you guys could confirm it fixes the issue would be great. ;)

Well, it seems @Sergey Sharybin (sergey) came across the same bug, and found a workaround for adding another mutex to dm_getLoopTriArray -> rB1a4442b3dbad

But applying only your solution also solves the bug

Tested with latest master, no more crash

mathieu menuet (bliblubli) raised the priority of this task from Confirmed, Medium to Needs Triage by Developer.Sep 19 2017, 5:34 PM

Thanks for the quick fix, but maybe only one fix would be enough? Don't know if the 2 fixes together may decrease performance?

mathieu menuet (bliblubli) triaged this task as Confirmed, Medium priority.Sep 19 2017, 5:34 PM