Python/BMesh: Crash on UV changes when handling depsgraph update - CDLayer re-allocation issue #67093
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#67093
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
System Information
Operating system: Windows 10
Graphics card: GTX970
Blender Version
Broken: Blender 2.8 RC1
Short description of error
On an addon I subscribe to the depsgraph update handler. The handler grabs some data via bmesh - its not changing anything.
Testing with the default cube - everything works fine, one can move uvs around without issues.
But on a cube with 6 subdivision (24k verts) - moving uvs results often in corruption and soon blender crashes.
Interesstingly doing regular vert transformation in the 3d view doens't create any issues as far as I can tell.
Exact steps for others to reproduce the error
depsgraph_update_corrupt_uvs.blend
Added subscriber: @kioku
#92620 was marked as duplicate of this issue
Added subscribers: @Sergey, @ideasman42, @dfelinto
Changed status from 'Open' to: 'Archived'
I get the crash even with a simple cube (and debug + ASAN build) and the following script (simplified from the reported one):
SUMMARY: AddressSanitizer: heap-use-after-free //source/blender/editors/transform/transform_conversions.c:3669 in flushTransUVs
Fullbacktrace: P1039
That said you are not freeing
bm
in your script. If you do that the crash goes away.Closing for now, but poking other devs in case I'm missing something here:
cc @Sergey @ideasman42
@dfelinto thank you for looking into this.
I forgot to try bm.free() in this case but I was under the impression that one should not call this for a bm bm.from_edit_mesh. I remember me having issues calling bm.free and finding this:
https://developer.blender.org/T39121
Changed status from 'Archived' to: 'Open'
Added subscriber: @mont29
@dfelinto, i don't think calling
bm.free()
is correct here. It doesn't make sense to free an internal data, and it only causes confusion in the script later on withAttributeError: 'bytes' object has no attribute 'faces'
.It seems that simply iterating over geometry confuses something with modal operator: possible re-allocations or tagging?
This isn't my area, leaving up to @ideasman42 and @mont29. I can reproduce the issue in 2.79, so doubt it's caused by the dependency graph or copy-on-write.
T67093_279.blend
Yes, bpy BM access seems to re-allocate some customdata memory, and since transform operator for UVs keeps a direct pointer to that UV CDLayer… it can do nothing but crash!
@ideasman42 I would rather leave this to you, think you have a much more complete view/understanding of those areas of code? I really do not see how to handle this case, besides not storing any pointer reference to CDLayer data from BMesh, in the modal operators.
Or maybe we should always ensure edit bmesh does have the
CD_BM_ELEM_PYPTR
? But that would only fix that case, any code adding some new layer will generate the same problem…Python: Crash on UV changes when handling depsgraph updateto Python/BMesh: Crash on UV changes when handling depsgraph update - CDLayer re-allocation issueAdded subscriber: @lichtwerk
#55954 (Python/BMesh: Add/removing textures between renders causes memory leak/ram crash) also seems to be related...
Added subscribers: @randum, @mano-wii