Fix #109583: Avoid allocation new custom loop normals for write #109671
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109671
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mod_moder:tmp_fix_data_race_to_compute_normals"
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?
Curve Deform node has never worked correctly.
This used to be a leaked copy made by each node
to write its own version of the custom loop normals.
Const correctness and sharing increased the chances of a crash.
e42064db77
toa61d126618
Fix #109583: Const version of mesh_calc_normals to only eval normals in geometry nodesto Fix #109583: Const version of mesh_calc_normals to only eval normals in geometry nodesFix #109583: Const version of mesh_calc_normals to only eval normals in geometry nodesto Fix #109583: Avoid allocation new custom loop normals for write@ -1890,0 +1887,4 @@
/* May be nullptr. Const_cast to avoid data race while normals computing from different threads
* for the same mesh. */
blender::short2 *clnors = const_cast<blender::short2 *>(static_cast<const blender::short2 *>(
CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL)));
That does not seem quite right to me. How can
BKE_mesh_calc_normals_split_ex
know that it is allowed to useconst_cast
and ignore implicit sharing?The problem was exactly that 10 nodes were taking it for the writing. Since there is only one real owner (only the object itself), different threads create new owners (that is, they simply add a reference count) and copy the data. But the data itself must continue to belong to the object. That is, now, the object must own all copies of this data for different threads. I really don't know how to fix this...
This doesn't look right.
For this reason, I'd rather just have a different version of the function (which would ignore this data). But Hans' suggestion was that it doesn't work just because of const correctness. If the streams will only read, everything should be fine. But they can still make a changes...
And a future normal refactoring might fix that..
If this is just a cache, then it should be protected by a mutex. I probably don't fully understand what's going on here right now.
10 curve deform nodes are asked to compute normals on a single object. Each of the nodes, through this function, requires the creation of local data for writing. And either a leak occurs, or now the reference counter is causing a crash ...
Although, now it seems to me that if each node creates its own copy of the mesh, implicit sharing will work correctly here.
#109695
Fix #109583: Avoid allocation new custom loop normals for writeto Fix #109583: Avoid allocation new custom loop normals for writeFix #109583: Avoid allocation new custom loop normals for writeto Fix #109583: Avoid allocation new custom loop normals for writePull request closed