Page MenuHome

Fix T95997: Crash when entering edit mode
ClosedPublic

Authored by Sergey Sharybin (sergey) on Feb 24 2022, 2:18 PM.

Details

Summary

The issue was uncovered by the 0f89bcdbebf5, but the root cause goes
into a much earlier design violation happened in the code: the modifier
evaluation function is modifying input mesh, which is not something
what is ever expected.

Bring code closer to the older state where such modification is only
done for the object in edit mode.


From own tests works seems to work fine, but extra eyes and testing
is needed.

Diff Detail

Repository
rB Blender
Branch
fix_T95997 (branched from master)
Build Status
Buildable 20715
Build 20715: arc lint + arc unit

Event Timeline

Sergey Sharybin (sergey) requested review of this revision.Feb 24 2022, 2:18 PM
Sergey Sharybin (sergey) created this revision.

I'm having trouble understanding what this fix does exactly.

As I understand it, modifying the input mesh is a problem because multiple objects might be referencing the same mesh/editmesh. There are no mutex locks so this is not thread safe. Now it is only modifying the input mesh for objects in edit mode, and not objects sharing the same mesh/editmesh which are not in edit mode.

However what about multiple objects in edit mode at the same time, that share the same mesh/editmesh?

I think it is only one object which will have ob->mode & OB_MODE_EDIT) even when you select multiple objects and go into edit mode. This is the check in object_update.c which was done before my changes in the rB0f89bcdbebf5.

I see multiple objects sharing a mesh while being in edit mode is not supported indeed, as per comments in ED_object_editmode_enter_ex.

It would be good to have a comment here explaining this, like:

/* Modifying the input mesh is weak, however as there can only be one object in edit mode
 * even if multiple are sharing the same mesh this should be thread safe. */

Seems to work ok in my tests.

Thanks Brecht for doublechecking and verifying finding about multriple objects sharing the same mesh in edit mode!

Indeed is a good idea to aff a comment about it. This is what this update is about: add comment.

Looks good, multiple windows and scenes work as well as they did previously

This revision is now accepted and ready to land.Mar 1 2022, 11:24 AM