Depsgraph: Fix 'use after free' error in some cases during undo step #106661
Closed
Bastien Montagne
wants to merge 1 commits from
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
F-fix-deg-memuse-after-free
into main
pull from: F-fix-deg-memuse-after-free
merge into: blender:main
blender:main
blender:brush-assets-project
blender:fix-121021
blender:blender-v3.3-release
blender:partial-write-refactor
blender:universal-scene-description
blender:blender-v4.1-release
blender:blender-v3.6-release
blender:blender-v3.6-temp_wmoss_animrig_public
blender:temp-sculpt-dyntopo
blender:gpencil-next
blender:anim/animation-id-113594
blender:blender-v4.0-release
blender:blender-projects-basics
blender:bridge-curves
blender:sculpt-blender
blender:asset-browser-frontend-split
blender:asset-shelf
blender:tmp-usd-python-mtl
blender:tmp-usd-3.6
blender:blender-v3.5-release
blender:blender-v2.93-release
blender:realtime-clock
blender:sculpt-dev
blender:bevelv2
blender:xr-dev
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 Commits
Author | SHA1 | Message | Date |
---|---|---|---|
Bastien Montagne | 7ee24e4d86 |
Depsgraph: Fix 'use after free' error in some cases during undo step.
The root of the issue seems to be that the depsgraph stores the name parts of its Component and Operation ID keys as string pointers, which may reffer to some data from the underlying ID. During undo, to reduce updates and speedup undo steps, a lot of IDs get 'replaced in place', i.e. new data read from the undo memfile is moved into the existing 'old' ID memory address. And the depsgraph is also re-used from the old BMain. Calling `DEG_id_tag_update` and similar on the ID can then cause depsgraph code to access freed memory from the 'old' data. To address this issue, this commit replaces the raw C string pointer by an std::string for both `ComponentIDKey` and `OperationIDKey` name. This has a performance cost on depsgraph building though, of about 6% to 7%. Depsgraph evaluation remains unchanged. |