Bad data editing by during DEG evaluation? #53800
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#53800
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Short description of error
Currently, creating a new static override from linked object in Blender (using spacebar-menu -> 'make_override') crashes in undo step creation code, due to use-after-free memory access.
Exact steps for others to reproduce the error
Detailed ASAN trace:
So looks like RNA diffing code (called from 'undo_step' function) is accessing some Object's data (ID props), while that same data is being replaced in threaded scene update.
I might be wrong here, but to me allowing deg evaluation to mess with 'real' data is pure evil, afaik we are trying to avoid that completely with CoW? But still, would be better to avoid that kind of behavior, this can also crash randomly when accessing data from py script (including UI) e.g.
Worth noting that with CoW enabled, it does not crash, btw.
Added subscriber: @mont29
Added subscriber: @dfelinto
Good news, I managed to reproduce this in a unit test: P638. I'm still not sure of what is going on though.
Technically we can remove this (
ob.collection_properties
) from the RNA. I added it there mostly because of the unittests - this way I could see if the dynamic override system was working.I would rather not remove it though. Can't we flag some RNA properties to be skipped from RNA diff? Or is this the only real-time data that is exposed via RNA (and written in threads)?
That won't change the fact that we are indeed creating run-time evaluation data in depsgraph. But I don't see the issue of this. It's not different than setting object final visibility via depsgraph, stored in its
ob->base_flag
.Added subscriber: @Sergey
This is either due to missed update flush to the object (which could be fixed from dependency graph side). But it is also very well possible is that flush is not needed on that object, and that you're just referencing freed data. Similar to what could happen with other evaluated data, like derived mesh.
On the one hand, you should skip evaluated data from diff. But on another hand, you can not skip object's data which will both be holding original datablock (for data from bmain) or evaluated datablock (for objects from depsgraph).
I would also think that make override should operate on the original datablock, which will not reference anything from it's collection properties. So, making CoW enabled by default (and not allowing to disable it) would solve the issue.
As discussed over IRC with Bastien, this can be fixed by ignoring real-time evaluated properties for the RNA diff
0c753c1dc4
.@dfelinto I will do that yes (though I could not reproduce crash with current blender2.8 anymore… go figure).
Point remains, that imho it should not be allowed for threaded depsgraph to directly affect data, not when something else might be running in main thread. Am a bit wondering how it is possible actually for main thread to be doing undo step, while depsgraph is running in some other threads? Is new deg using a deferred/background? I would expect DEG to call 'process tasks and wait' from main thread…
This issue was referenced by
13f80a152a
Changed status from 'Open' to: 'Resolved'
@mont29, the only case when depsgraph might change some of the data is for things like material review. But those don't use objects from main bmain, only materials are shared and no write to them is happening to my knowledge. Undo step is supposed to stop all the running jobs.
Depsgraph does not do any deferred tasks, all its threads are done after
DEG_evaluate_on_refresh()
andDEG_evaluate_on_framechange()
are done.Possible reasons why depsgraph threads are active during undo:
Are you sure there are depsgraph threads active during undo? To me it seems more like due to changes in relations, some of the runtime only-data is not evaluated/assigned by dependency graph (since object is no longer in the graph or so), but is being accessed by generic RNA traversal algorithm (which dereferences previously assigned pointer).
@Sergey It’s hard to be sure of anything, especially since I cannot reproduce the issue anymore currently. But, reading ASAN report from initial post:
idproperty_reset()
, and that func immediately re-assign object->base_collection_properties with newly allocated mem.I’m not sure to see how this access-after-free could happen, besides a concurrent situation between execution of RNA accessor (from undo code) and idproperty_reset (from DEG)?
Note that thread14 is created from
DEG_graph_flush_update()
, triggered from RNA's Scene.update() (py API), not regular DEG process I believe? At least, it does not seem to go throughDEG_evaluate_on_refresh()
norDEG_evaluate_on_framechange()
…@mont29, this doesn't necessarily mean that both threads are running outside. What could be happening is:
Either that, or object is not tagged for update, and hence it doesn't receive updated pointer for collection properties.
The point here is: it is not necessarily a concurrent access, such a bad memory access might happen in a "linear" fashion.
What we can try doing, is to NULL all runtime fields when object goes away from graph. But don't think it's really needed to be done now, with CoW this will happen auto-magically: evaluated fields will only be written to object owned by Depsgraph. So undo system will not see them. And then, if some object is not part of depsgraph anymore, it is gone forever.
Yes, agree that CoW should make that kind of issue history, so let’s wait and hope for the Mighty CoW! :)