regression can't open file in 2.79 (crash) #52816

Closed
opened 2017-09-18 16:15:33 +02:00 by mathieu menuet · 19 comments

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
crash visibility layer 274.blend

**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 [crash visibility layer 274.blend](https://archive.blender.org/developer/F812984/crash_visibility_layer_274.blend)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @bliblubli

Added subscriber: @bliblubli

Added subscriber: @mont29

Added subscriber: @mont29

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?

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](https://builder.blender.org/download)?
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

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.

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.
Member

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- [x] is pointing to uninitialized ram.

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- [x] is pointing to uninitialized ram.
Bastien Montagne self-assigned this 2017-09-18 21:52:31 +02:00

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.

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.
Member

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

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

Added subscriber: @mano-wii

Added subscriber: @mano-wii

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;
 
 	DM_ensure_looptri_data(dm);
+	struct MLoopTri *array = dm->looptris.array;
+	dm->looptris.array = NULL;
 
 	BKE_mesh_recalc_looptri(
 	        cddm->mloop, cddm->mpoly,
 	        cddm->mvert,
 	        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)

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; DM_ensure_looptri_data(dm); + struct MLoopTri *array = dm->looptris.array; + dm->looptris.array = NULL; BKE_mesh_recalc_looptri( cddm->mloop, cddm->mpoly, cddm->mvert, 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.

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.

This issue was referenced by 9591b5f618

This issue was referenced by 9591b5f6182f754dc06e1aff43d6b8b675aa9bf4

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

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

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

Added subscriber: @Sergey

Added subscriber: @Sergey

In #52816#460918, @mont29 wrote:
Note that 9591b5f618 is tentative fix (based on @mano-wii's work), if one of you guys could confirm it fixes the issue would be great. ;)

Well, it seems @Sergey came across the same bug, and found a workaround for adding another mutex to dm_getLoopTriArray -> 1a4442b3db

But applying only your solution also solves the bug

> In #52816#460918, @mont29 wrote: > Note that 9591b5f618 is tentative fix (based on @mano-wii's work), if one of you guys could confirm it fixes the issue would be great. ;) Well, it seems @Sergey came across the same bug, and found a workaround for adding another mutex to `dm_getLoopTriArray` -> 1a4442b3db But applying only your solution also solves the bug
Member

Tested with latest master, no more crash

Tested with latest master, no more crash
Author

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

Thanks for the quick fix, but maybe only one fix would be enough? Don't know if the 2 fixes together may decrease performance?
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#52816
No description provided.