Regression: Geometry Nodes: Access Violation Exception when copying from Mesh with GPU Subdivision Surface Modifier #113377

Open
opened 2023-10-07 01:50:22 +02:00 by gummi · 13 comments

System Information
Operating system: Windows 10 Pro
Graphics card: NVIDIA GeForce RTX 3060 Ti

Blender Version
Broken: version: 3.5.0 Alpha, branch: master, commit date: 2022-11-11 21:32, hash: rB03ccf37162d3
Worked: version: 3.5.0 Alpha, branch: master, commit date: 2022-11-10 21:29, hash: rBca1642cd0c5c

Short description of error

I was fiddling around with steps to reproduce an earlier report issues/113358, but stumbled across another way to crash blender with an access violation (might be related, might not). Setting up a scene where a base object has a subdivision modifier from which another object then copies causes a crash when you try to edit both at once. Other generative modifiers don't seem to be affected.

Interestingly, this crash does not occur when both objects have mesh data with the same layout (i.e. both are cubes/spheres/monkeys as created by the add mesh operator)

Steps to Crash

1.Open the file CopyDataCrash.blend.
2. Select Cube.001 and Outline.001 (the order doesn't seem to matter).
3. Try tabbing into edit mode.
4. at this point, blender should have crashed with an EXCEPTION_ACCESS_VIOLATION (Report CopyDataCrash.crash.txt attached).

The other cube+outline objects are included to show that only the subdivision surface modifier seems to be affected. Using the same steps on those groups does not produce a crash.

Workarounds
Any one of these will prevent a crash:

  1. Disabling Edit Mode Display of either the Subdivision Surface Modifier on Cube.001 or the Geometry Nodes on Outline.001.
  2. Applying either modifier.
  3. Adding a cube mesh to Outline.001 in edit mode (such that both Cube.001 and Outline.001 have the same amount/layout of faces).
System Information Operating system: Windows 10 Pro Graphics card: NVIDIA GeForce RTX 3060 Ti Blender Version Broken: version: 3.5.0 Alpha, branch: master, commit date: 2022-11-11 21:32, hash: `rB03ccf37162d3` Worked: version: 3.5.0 Alpha, branch: master, commit date: 2022-11-10 21:29, hash: `rBca1642cd0c5c` **Short description of error** I was fiddling around with steps to reproduce an earlier report [issues/113358](issues/113358), but stumbled across another way to crash blender with an access violation (might be related, might not). Setting up a scene where a base object has a subdivision modifier from which another object then copies causes a crash when you try to edit both at once. Other generative modifiers don't seem to be affected. Interestingly, this crash does not occur when both objects have mesh data with the same layout (i.e. both are cubes/spheres/monkeys as created by the add mesh operator) **Steps to Crash** 1.Open the file [CopyDataCrash.blend](/attachments/7fc6b354-a8d6-41ed-98b3-0cb7e8551ff4). 2. Select `Cube.001` and `Outline.001` (the order doesn't seem to matter). 3. Try tabbing into edit mode. 4. at this point, blender should have crashed with an `EXCEPTION_ACCESS_VIOLATION` (Report [CopyDataCrash.crash.txt](/attachments/ab1b6231-cdc5-4ce6-878d-ff85e2558e37) attached). The other cube+outline objects are included to show that only the subdivision surface modifier seems to be affected. Using the same steps on those groups does not produce a crash. **Workarounds** Any one of these will prevent a crash: 1. Disabling Edit Mode Display of either the Subdivision Surface Modifier on `Cube.001` or the Geometry Nodes on `Outline.001`. 2. Applying either modifier. 3. Adding a cube mesh to `Outline.001` in edit mode (such that both `Cube.001` and `Outline.001` have the same amount/layout of faces).
gummi added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-10-07 01:50:23 +02:00
No description provided.
Iliya Katushenock changed title from Geometry Nodes | Access Violation Exception when copying from Mesh with Subdivision Surface Modifier to Regression: Geometry Nodes: Access Violation Exception when copying from Mesh with GPU Subdivision Surface Modifier 2023-10-07 14:16:13 +02:00
Iliya Katushenock added this to the 3.6 LTS milestone 2023-10-07 14:17:37 +02:00

I really don't know who is causer, there are too many potential causes:

On the one hand, all this seems indirectly related, but at the same time i won’t say that anyone is definitely guilty, since it’s clearly not directly related.

I really don't know who is causer, there are too many potential causes: - 88c956c13be40aeaaf3828369ab63801413fef82 / @Jeroen-Bakker - ff7645c5edd211c5317b5fd9e6d0320c20667a21 / @HooglyBoogly - 6295bdfd38d3a4be8ee34ea6648473b4bbddf504 / @JacquesLucke On the one hand, all this seems indirectly related, but at the same time i won’t say that anyone is definitely guilty, since it’s clearly not directly related.
Member

88c956c13b should only impacts rendering, not viewport drawing. Has anyone been able to reproduce the issue? We could revert this commit and see if it still fails.

I agree that the other mentioned commits aren't directly related.

88c956c13be40aeaaf3828369ab63801413fef82 should only impacts rendering, not viewport drawing. Has anyone been able to reproduce the issue? We could revert this commit and see if it still fails. I agree that the other mentioned commits aren't directly related.
Member

Up to date call stack. (Blender 4.1)

__pthread_kill_implementation (@pthread_kill@@GLIBC_2.34:81)
__pthread_kill_internal (@pthread_kill@@GLIBC_2.34:59)
__GI___pthread_kill (@pthread_kill@@GLIBC_2.34:59)
__GI_raise (@raise:10)
__GI_abort (@abort:46)
_BLI_assert_abort (/home/jeroen/blender-git/blender/source/blender/blenlib/intern/BLI_assert.c:48)
BM_face_at_index (/home/jeroen/blender-git/blender/source/blender/bmesh/intern/bmesh_mesh.h:120)
bm_original_face_get (/home/jeroen/blender-git/blender/source/blender/draw/intern/mesh_extractors/extract_mesh.hh:190)
::draw_subdiv_cache_extra_coarse_face_data_mapped(Mesh *, BMesh *, MeshRenderData &, uint32_t *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:782)
::draw_subdiv_cache_update_extra_coarse_face_data(DRWSubdivCache &, Mesh *, MeshRenderData &) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:815)
::draw_subdiv_create_requested_buffers(Object *, Mesh *, MeshBatchCache &, MeshBufferCache &, const bool, const bool, const bool, const float (*)[4], const bool, const bool, const bool, const ToolSettings *, const bool, OpenSubdiv_EvaluatorCache *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:2173)
::DRW_create_subdivision(Object *, Mesh *, MeshBatchCache &, MeshBufferCache *, const bool, const bool, const bool, const float (*)[4], const bool, const bool, const bool, const ToolSettings *, const bool) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:2325)
DRW_mesh_batch_cache_create_requested(TaskGraph*, Object*, Mesh*, Scene const*, bool, bool) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_mesh.cc:1900)
::drw_batch_cache_generate_requested(Object *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache.cc:3358)
::drw_engines_cache_populate(Object *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_manager_c.cc:1089)
::DRW_draw_render_loop_ex(Depsgraph *, RenderEngineType *, ARegion *, View3D *, GPUViewport *, const bContext *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_manager_c.cc:1728)
::DRW_draw_view(const bContext *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_manager_c.cc:1632)
::view3d_draw_view(const bContext *, ARegion *) (/home/jeroen/blender-git/blender/source/blender/editors/space_view3d/view3d_draw.cc:1595)
::view3d_main_region_draw(const bContext *, ARegion *) (/home/jeroen/blender-git/blender/source/blender/editors/space_view3d/view3d_draw.cc:1629)
ED_region_do_draw(bContext*, ARegion*) (/home/jeroen/blender-git/blender/source/blender/editors/screen/area.cc:532)

It seems like inconsistency in the data model.

Up to date call stack. (Blender 4.1) ``` __pthread_kill_implementation (@pthread_kill@@GLIBC_2.34:81) __pthread_kill_internal (@pthread_kill@@GLIBC_2.34:59) __GI___pthread_kill (@pthread_kill@@GLIBC_2.34:59) __GI_raise (@raise:10) __GI_abort (@abort:46) _BLI_assert_abort (/home/jeroen/blender-git/blender/source/blender/blenlib/intern/BLI_assert.c:48) BM_face_at_index (/home/jeroen/blender-git/blender/source/blender/bmesh/intern/bmesh_mesh.h:120) bm_original_face_get (/home/jeroen/blender-git/blender/source/blender/draw/intern/mesh_extractors/extract_mesh.hh:190) ::draw_subdiv_cache_extra_coarse_face_data_mapped(Mesh *, BMesh *, MeshRenderData &, uint32_t *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:782) ::draw_subdiv_cache_update_extra_coarse_face_data(DRWSubdivCache &, Mesh *, MeshRenderData &) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:815) ::draw_subdiv_create_requested_buffers(Object *, Mesh *, MeshBatchCache &, MeshBufferCache &, const bool, const bool, const bool, const float (*)[4], const bool, const bool, const bool, const ToolSettings *, const bool, OpenSubdiv_EvaluatorCache *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:2173) ::DRW_create_subdivision(Object *, Mesh *, MeshBatchCache &, MeshBufferCache *, const bool, const bool, const bool, const float (*)[4], const bool, const bool, const bool, const ToolSettings *, const bool) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_subdivision.cc:2325) DRW_mesh_batch_cache_create_requested(TaskGraph*, Object*, Mesh*, Scene const*, bool, bool) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache_impl_mesh.cc:1900) ::drw_batch_cache_generate_requested(Object *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_cache.cc:3358) ::drw_engines_cache_populate(Object *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_manager_c.cc:1089) ::DRW_draw_render_loop_ex(Depsgraph *, RenderEngineType *, ARegion *, View3D *, GPUViewport *, const bContext *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_manager_c.cc:1728) ::DRW_draw_view(const bContext *) (/home/jeroen/blender-git/blender/source/blender/draw/intern/draw_manager_c.cc:1632) ::view3d_draw_view(const bContext *, ARegion *) (/home/jeroen/blender-git/blender/source/blender/editors/space_view3d/view3d_draw.cc:1595) ::view3d_main_region_draw(const bContext *, ARegion *) (/home/jeroen/blender-git/blender/source/blender/editors/space_view3d/view3d_draw.cc:1629) ED_region_do_draw(bContext*, ARegion*) (/home/jeroen/blender-git/blender/source/blender/editors/screen/area.cc:532) ``` It seems like inconsistency in the data model.
Jeroen Bakker added
Interest
EEVEE & Viewport
Type
Bug
Module
EEVEE & Viewport
and removed
Module
Core
Type
Report
labels 2023-10-09 14:59:46 +02:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-10-09 14:59:51 +02:00
Member

I will assign it to EEVEE/Viewport module as the crash occurs there.

I will assign it to EEVEE/Viewport module as the crash occurs there.
Member

When switching to edit mode it seems like one bmesh instance doesn't match the mesh it represents. Its faces, edges and vertices are empty. Which crashes blender. So it might be that the input data isn't complete.

DRW_create_subdivision -> draw_subdiv_create_requested_buffers.

When switching to edit mode it seems like one bmesh instance doesn't match the mesh it represents. Its faces, edges and vertices are empty. Which crashes blender. So it might be that the input data isn't complete. `DRW_create_subdivision` -> `draw_subdiv_create_requested_buffers`.
Member

Same callstack as in #114141

Same callstack as in #114141
Member

Will dare setting this to High priority (since this is a crasher which is not too uncommon to run into)

Will dare setting this to High priority (since this is a crasher which is not too uncommon to run into)
Philipp Oeser added
Priority
High
and removed
Priority
Normal
labels 2024-02-13 14:50:47 +01:00
Member

I've been taking a look at this.
I can avoid the crash by checking if bm->totface == mr.face_len in draw_subdiv_cache_extra_coarse_face_data_mapped.

diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
index 806181eeee7..be7f8a388d9 100644
--- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc
+++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
@@ -775,7 +775,7 @@ static void draw_subdiv_cache_extra_coarse_face_data_mapped(Mesh *mesh,
                                                             MeshRenderData &mr,
                                                             uint32_t *flags_data)
 {
-  if (bm == nullptr) {
+  if (bm == nullptr || bm->totface != mr.face_len) {
     draw_subdiv_cache_extra_coarse_face_data_mesh(mr, mesh, flags_data);
     return;
   }

But that's more a hacky workaround than a fix.
I guess a proper fix would be to check if there's any meaningful mapping between the edit and the eval mesh at mesh_render_data_create and don't set the origindex variables when there isn't (?).
But I don't see any way to do so. Maybe @HooglyBoogly can shed some light?

I've been taking a look at this. I can avoid the crash by checking if `bm->totface == mr.face_len` in `draw_subdiv_cache_extra_coarse_face_data_mapped`. ```diff diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 806181eeee7..be7f8a388d9 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -775,7 +775,7 @@ static void draw_subdiv_cache_extra_coarse_face_data_mapped(Mesh *mesh, MeshRenderData &mr, uint32_t *flags_data) { - if (bm == nullptr) { + if (bm == nullptr || bm->totface != mr.face_len) { draw_subdiv_cache_extra_coarse_face_data_mesh(mr, mesh, flags_data); return; } ``` But that's more a hacky workaround than a fix. I guess a proper fix would be to check if there's any meaningful mapping between the edit and the eval mesh at `mesh_render_data_create` and don't set the `origindex` variables when there isn't (?). But I don't see any way to do so. Maybe @HooglyBoogly can shed some light?
Member

The point of this draw_subdiv_cache_extra_coarse_face_data_mapped code path is to reasonably extract edit mesh data for the corresponding faces in the evaluated mesh. The p_origindex map means it's supposed to be fine if the number of faces don't match. SO I don't think that's the right solution. But I'll spend some time looking into this and see if I can find something.

The point of this `draw_subdiv_cache_extra_coarse_face_data_mapped` code path is to reasonably extract edit mesh data for the corresponding faces in the evaluated mesh. The `p_origindex` map means it's supposed to be fine if the number of faces don't match. SO I don't think that's the right solution. But I'll spend some time looking into this and see if I can find something.
Member

The problem here is the combination of the object info node with both object's in edit mode. The source object's mesh has CD_ORIGINDEX layers referring to its own edit mesh, then the second object uses those mapping layers when its own edit mesh is empty.

I think the fix here is to properly propagate the Mesh::edit_mesh pointer through the modifier stack, including nodes, instead of just setting the pointers at the end of evaluation as currently happens in editbmesh_build_data. That way, when the mesh is completely replaced from a mesh from another object, the edit mesh pointer from that object would come with it.

Design wise, that's basically how the current code "should" be working. But it's probably not trivial. So maybe we can find a temporary fix too.

The problem here is the combination of the object info node with both object's in edit mode. The source object's mesh has `CD_ORIGINDEX` layers referring to its own edit mesh, then the second object uses those mapping layers when its own edit mesh is empty. I think the fix here is to properly propagate the `Mesh::edit_mesh` pointer through the modifier stack, including nodes, instead of just setting the pointers at the end of evaluation as currently happens in `editbmesh_build_data`. That way, when the mesh is completely replaced from a mesh from another object, the edit mesh pointer from that object would come with it. Design wise, that's basically how the current code "should" be working. But it's probably not trivial. So maybe we can find a temporary fix too.

Maybe CD_ORIGINDEX layers should be cleared when importing geometry into another object's geometry node tree? So that there is no mapping.

Mapping face selection from one object to another object seems tricky, and probably enough of a corner case that it's not worth supporting.

Maybe `CD_ORIGINDEX` layers should be cleared when importing geometry into another object's geometry node tree? So that there is no mapping. Mapping face selection from one object to another object seems tricky, and probably enough of a corner case that it's not worth supporting.
Member

That's probably the best short term fix. But it's also not trivial. Currently I'm not sure we can do that without destroying visibility of object instances, etc. in the object info node. But it could be doable.

I do think that assigning the active object's edit_mesh pointer to an evaluated mesh derived from a completely different object is wrong though. I'd like that to be solved so we wouldn't run into this problem eventually too.

That's probably the best short term fix. But it's also not trivial. Currently I'm not sure we can do that without destroying visibility of object instances, etc. in the object info node. But it could be doable. I do think that assigning the active object's `edit_mesh` pointer to an evaluated mesh derived from a completely different object is wrong though. I'd like that to be solved so we wouldn't run into this problem eventually too.
Sign in to join this conversation.
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 Assignees
7 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113377
No description provided.