Page MenuHome

Fix T86561: Crash when entering edit mode with multiple objects sharing the same mesh
AbandonedPublic

Authored by Cian Jinks (Hobbes) on Mar 14 2021, 4:43 PM.

Details

Summary

This small patch aims to fix T86561.

Problem:
Selecting two objects with linked object data in the reverse order to which they were linked while in Object Mode and then attempting to enter Edit Mode causes a crash.

Where the problem lies:
The LISTBASE_FOREACH loop modified in the diff did not take into account the case where multiple objects are different but have the same object data pointer. In the case where one of these objects is the obact pointer there is a problem. If this obact object comes after the others in the loop, it's id->tag is already updated previously, meaning len is not updated correctly causing r_active_index to be set incorrectly also. This causes a segmentation fault further down the line.

Fix:
Therefore, my proposed fix is a simple if statement which gurantees that if the object whose object data tag is being updated is not the obact object, then it is also not one of the other objects who share the same object data as the obact object.

Note:
While the original ticket only showed the case where two objects have linked object data, the crash does infact occur for any number of linked objects and this fix works regardless.

Diff Detail

Repository
rB Blender

Event Timeline

Cian Jinks (Hobbes) requested review of this revision.Mar 14 2021, 4:43 PM
Cian Jinks (Hobbes) created this revision.

Thanks for the fix, while it works I ended up committing an alternate solution. rB0a34fec56a2f8d051a1348d4e82049e063ffcc37