Crash when toggling edit mode on object with geometry node modifier, but only if the instanced objects material has a normal map assigned. #91838

Closed
opened 2021-09-30 14:33:18 +02:00 by Lino Thomas · 13 comments

System Information
Operating system: Win 10
Graphics card: GTX 1080ti

Blender Version
Broken: 2.93.4/ 2.93.5 / 3.0 alpha
Worked: -

Short description of error
I created a "radial array" geometry node group and have given object "B" this modifier.
Object "A" is being instanced via this node group into a radial array.
When toggling the edit mode on the "B" object, Blender crashes.
Blender does not crash, if i disconnect the normal map socket from the material used on object "A".

Exact steps for others to reproduce the error
crash_packed.blend
Open the blend file and press "tab". (object "B" is preselected).
Blender should crash now.

To not have it crash, disconnect the normal socked in the material.
(I added annotations in the shader editor to highlight the connection.)

I hope thats all, thank you for being awesome :)

**System Information** Operating system: Win 10 Graphics card: GTX 1080ti **Blender Version** Broken: 2.93.4/ 2.93.5 / 3.0 alpha Worked: - **Short description of error** I created a "radial array" geometry node group and have given object "B" this modifier. Object "A" is being instanced via this node group into a radial array. When toggling the edit mode on the "B" object, Blender crashes. Blender does not crash, if i disconnect the normal map socket from the material used on object "A". **Exact steps for others to reproduce the error** [crash_packed.blend](https://archive.blender.org/developer/F10691435/crash_packed.blend) Open the blend file and press "tab". (object "B" is preselected). Blender should crash now. To not have it crash, disconnect the normal socked in the material. (I added annotations in the shader editor to highlight the connection.) I hope thats all, thank you for being awesome :)
Author

Added subscriber: @LinoThomas

Added subscriber: @LinoThomas

Added subscriber: @iss

Added subscriber: @iss

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Can confirm crash on NULL dereference

P2460: (An Untitled Masterwork)

 	blender.exe!GPU_vertformat_safe_attr_name(const char * attr_name, char * r_safe_name, unsigned int UNUSED_max_len) Line 279	C++
>	blender.exe!blender::draw::extract_tan_ex_init(const MeshRenderData * mr, MeshBatchCache * cache, GPUVertBuf * vbo, const bool do_hq) Line 147	C++
 	blender.exe!blender::draw::extract_tan_init(const MeshRenderData * mr, MeshBatchCache * cache, void * buf, void * UNUSED_tls_data) Line 220	C++
 	blender.exe!blender::draw::extract_init(const MeshRenderData * mr, MeshBatchCache * cache, blender::draw::ExtractorRunDatas & extractors, MeshBufferList * mbuflist, void * data_stack) Line 220	C++
 	blender.exe!blender::draw::extract_task_range_run(void * taskdata) Line 454	C++
 	blender.exe!TaskNode::run(const tbb::flow::interface11::continue_msg UNUSED_input) Line 95	C++
 	blender.exe!TaskNode::<lambda>(const tbb::flow::interface11::continue_msg input) Line 70	C++
 	blender.exe!tbb::flow::interface11::internal::function_body_leaf<tbb::flow::interface11::continue_msg,tbb::flow::interface11::continue_msg,void <lambda>(const tbb::flow::interface11::continue_msg)>::operator()(const tbb::flow::interface11::continue_msg & i) Line 147	C++
 	blender.exe!tbb::flow::interface11::internal::continue_input<tbb::flow::interface11::continue_msg,tbb::flow::interface11::internal::Policy<void>>::apply_body_bypass(tbb::flow::interface11::continue_msg __formal) Line 822	C++
 	blender.exe!tbb::flow::interface11::internal::apply_body_task_bypass<tbb::flow::interface11::internal::continue_input<tbb::flow::interface11::continue_msg,tbb::flow::interface11::internal::Policy<void>>,tbb::flow::interface11::continue_msg>::execute() Line 312	C++
 	[External Code]	
 	blender.exe!tbb::task::wait_for_all() Line 821	C++
 	blender.exe!tbb::flow::interface10::graph::wait_functor::operator()() Line 252	C++
 	blender.exe!tbb::interface7::internal::delegated_function<tbb::flow::interface10::graph::wait_functor const ,void>::operator()() Line 97	C++
 	[External Code]	
 	blender.exe!tbb::interface7::task_arena::execute_impl<void,tbb::flow::interface10::graph::wait_functor const>(const tbb::flow::interface10::graph::wait_functor & f) Line 272	C++
 	blender.exe!tbb::interface7::task_arena::execute<tbb::flow::interface10::graph::wait_functor>(const tbb::flow::interface10::graph::wait_functor & f) Line 434	C++
 	blender.exe!tbb::flow::interface10::graph::wait_for_all() Line 347	C++
 	blender.exe!BLI_task_graph_work_and_wait(TaskGraph * task_graph) Line 129	C++
 	blender.exe!DRW_mesh_batch_cache_create_requested(TaskGraph * task_graph, Object * ob, Mesh * me, const Scene * scene, const bool is_paint_mode, const bool use_hide) Line 1830	C
 	blender.exe!drw_batch_cache_generate_requested(Object * ob) Line 3435	C
 	blender.exe!drw_engines_cache_populate(Object * ob) Line 1061	C
 	blender.exe!DRW_draw_render_loop_ex(Depsgraph * depsgraph, RenderEngineType * engine_type, ARegion * region, View3D * v3d, GPUViewport * viewport, const bContext * evil_C) Line 1582	C
 	blender.exe!DRW_draw_view(const bContext * C) Line 1489	C
 	blender.exe!view3d_draw_view(const bContext * C, ARegion * region) Line 1566	C
 	blender.exe!view3d_main_region_draw(const bContext * C, ARegion * region) Line 1589	C
 	blender.exe!ED_region_do_draw(bContext * C, ARegion * region) Line 569	C
 	blender.exe!wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) Line 729	C
 	blender.exe!wm_draw_window(bContext * C, wmWindow * win) Line 880	C
 	blender.exe!wm_draw_update(bContext * C) Line 1079	C
 	blender.exe!WM_main(bContext * C) Line 654	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 562	C
 	[External Code]	

Can confirm crash on NULL dereference [P2460: (An Untitled Masterwork)](https://archive.blender.org/developer/P2460.txt) ``` blender.exe!GPU_vertformat_safe_attr_name(const char * attr_name, char * r_safe_name, unsigned int UNUSED_max_len) Line 279 C++ > blender.exe!blender::draw::extract_tan_ex_init(const MeshRenderData * mr, MeshBatchCache * cache, GPUVertBuf * vbo, const bool do_hq) Line 147 C++ blender.exe!blender::draw::extract_tan_init(const MeshRenderData * mr, MeshBatchCache * cache, void * buf, void * UNUSED_tls_data) Line 220 C++ blender.exe!blender::draw::extract_init(const MeshRenderData * mr, MeshBatchCache * cache, blender::draw::ExtractorRunDatas & extractors, MeshBufferList * mbuflist, void * data_stack) Line 220 C++ blender.exe!blender::draw::extract_task_range_run(void * taskdata) Line 454 C++ blender.exe!TaskNode::run(const tbb::flow::interface11::continue_msg UNUSED_input) Line 95 C++ blender.exe!TaskNode::<lambda>(const tbb::flow::interface11::continue_msg input) Line 70 C++ blender.exe!tbb::flow::interface11::internal::function_body_leaf<tbb::flow::interface11::continue_msg,tbb::flow::interface11::continue_msg,void <lambda>(const tbb::flow::interface11::continue_msg)>::operator()(const tbb::flow::interface11::continue_msg & i) Line 147 C++ blender.exe!tbb::flow::interface11::internal::continue_input<tbb::flow::interface11::continue_msg,tbb::flow::interface11::internal::Policy<void>>::apply_body_bypass(tbb::flow::interface11::continue_msg __formal) Line 822 C++ blender.exe!tbb::flow::interface11::internal::apply_body_task_bypass<tbb::flow::interface11::internal::continue_input<tbb::flow::interface11::continue_msg,tbb::flow::interface11::internal::Policy<void>>,tbb::flow::interface11::continue_msg>::execute() Line 312 C++ [External Code] blender.exe!tbb::task::wait_for_all() Line 821 C++ blender.exe!tbb::flow::interface10::graph::wait_functor::operator()() Line 252 C++ blender.exe!tbb::interface7::internal::delegated_function<tbb::flow::interface10::graph::wait_functor const ,void>::operator()() Line 97 C++ [External Code] blender.exe!tbb::interface7::task_arena::execute_impl<void,tbb::flow::interface10::graph::wait_functor const>(const tbb::flow::interface10::graph::wait_functor & f) Line 272 C++ blender.exe!tbb::interface7::task_arena::execute<tbb::flow::interface10::graph::wait_functor>(const tbb::flow::interface10::graph::wait_functor & f) Line 434 C++ blender.exe!tbb::flow::interface10::graph::wait_for_all() Line 347 C++ blender.exe!BLI_task_graph_work_and_wait(TaskGraph * task_graph) Line 129 C++ blender.exe!DRW_mesh_batch_cache_create_requested(TaskGraph * task_graph, Object * ob, Mesh * me, const Scene * scene, const bool is_paint_mode, const bool use_hide) Line 1830 C blender.exe!drw_batch_cache_generate_requested(Object * ob) Line 3435 C blender.exe!drw_engines_cache_populate(Object * ob) Line 1061 C blender.exe!DRW_draw_render_loop_ex(Depsgraph * depsgraph, RenderEngineType * engine_type, ARegion * region, View3D * v3d, GPUViewport * viewport, const bContext * evil_C) Line 1582 C blender.exe!DRW_draw_view(const bContext * C) Line 1489 C blender.exe!view3d_draw_view(const bContext * C, ARegion * region) Line 1566 C blender.exe!view3d_main_region_draw(const bContext * C, ARegion * region) Line 1589 C blender.exe!ED_region_do_draw(bContext * C, ARegion * region) Line 569 C blender.exe!wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) Line 729 C blender.exe!wm_draw_window(bContext * C, wmWindow * win) Line 880 C blender.exe!wm_draw_update(bContext * C) Line 1079 C blender.exe!WM_main(bContext * C) Line 654 C blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 562 C [External Code] ```
Member

Added subscriber: @HooglyBoogly

Added subscriber: @HooglyBoogly
Member

There is a null reference in GPU_vertformat_safe_attr_name because the CD_TANGENT layer does not exist. I'm not sure how related this is to geometry nodes honestly.

There is a null reference in `GPU_vertformat_safe_attr_name` because the `CD_TANGENT` layer does not exist. I'm not sure how related this is to geometry nodes honestly.
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Also can't see how geometry nodes could cause this right now, but I also didn't manage to reproduce it without geometry nodes yet.
I was able to reproduce it in a new scene:

  1. Duplicate the default cube (with alt+d so that the mesh is shared).
  2. Add geometry nodes to the new cube. Add an Object Info node that loads the other cube and pass the geometry to the group output. Enable As Instance in the Object Info node.
  3. Add a Normal Map node to the shader of the cubes and link it to the Normal input of the Principled BSDF.
  4. Switch to material preview mode.
  5. Try to enter edit mode.

With the file just try to enter edit mode on the selected object.

tangent_bug.blend

2021-11-02_19-14.png

[EDIT: the bug I found below has been fixed separately]
I also ran into another issue in this setup, but it seems unrelated: P2566. This happens when I leave As Instance off, and when I exit edit mode on the other cube..
Looks like me->edit_mesh->mesh_eval_cage == me->edit_mesh->mesh_eval_cage->edit_mesh->mesh_eval_cage for some reason. This leads to infinite recursion.

Also can't see how geometry nodes could cause this right now, but I also didn't manage to reproduce it without geometry nodes yet. I was able to reproduce it in a new scene: 1. Duplicate the default cube (with alt+d so that the mesh is shared). 2. Add geometry nodes to the new cube. Add an Object Info node that loads the other cube and pass the geometry to the group output. Enable As Instance in the Object Info node. 3. Add a Normal Map node to the shader of the cubes and link it to the Normal input of the Principled BSDF. 4. Switch to material preview mode. 5. Try to enter edit mode. With the file just try to enter edit mode on the selected object. [tangent_bug.blend](https://archive.blender.org/developer/F11680397/tangent_bug.blend) ![2021-11-02_19-14.png](https://archive.blender.org/developer/F11680414/2021-11-02_19-14.png) [EDIT: the bug I found below has been fixed separately] I also ran into another issue in this setup, but it seems unrelated: [P2566](https://archive.blender.org/developer/P2566.txt). This happens when I leave As Instance off, and when I exit edit mode on the other cube.. Looks like `me->edit_mesh->mesh_eval_cage == me->edit_mesh->mesh_eval_cage->edit_mesh->mesh_eval_cage` for some reason. This leads to infinite recursion.

Added subscriber: @fclem

Added subscriber: @fclem

After digging the issue, I came to a point where it seems that
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final); in mesh_cd_calc_used_gpu_layers
does not contains the same layers as
CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata; in extract_tan_ex_init
which makes tangent layer generation to fail.

In BKE_mesh_calc_loop_tangent_step_0, DM_TANGENT_MASK_ORCO is only added to the tangent mask if there is no uv layer. mesh_cd_calc_used_gpu_layers does not see any UVs, thus query only orco tangent layer. But BKE_mesh_calc_loop_tangent_step_0 will not create the tangent layer since there is a valid UV layer to query a tangent layer from, but it does not match any requested tangent layer name (because only orco was needed).

I tried (P2572) to make tangent orco generation work even in the presence of valid UV layer but couldn't make it work (CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") still returns -1 even after CustomData_add_layer_named(loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");). It not help because the rest of the generation code also assumes the same thing as BKE_mesh_calc_loop_tangent_step_0 (that orco is only here as fallback).

To me all of this is quite fragile since this means everything needs to have the same behavior and be in sync for things to never fail.

The real fix is likely to fix the premise of the issue, which is that cd_ldata differs between eval and request. But I wouldn't know how to fix that.

After digging the issue, I came to a point where it seems that `const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);` in `mesh_cd_calc_used_gpu_layers` does not contains the same layers as `CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;` in `extract_tan_ex_init` which makes tangent layer generation to fail. In `BKE_mesh_calc_loop_tangent_step_0`, `DM_TANGENT_MASK_ORCO` is only added to the tangent mask if there is no uv layer. `mesh_cd_calc_used_gpu_layers` does not see any UVs, thus query only orco tangent layer. But `BKE_mesh_calc_loop_tangent_step_0` will not create the tangent layer since there is a valid UV layer to query a tangent layer from, but it does not match any requested tangent layer name (because only orco was needed). I tried ([P2572](https://archive.blender.org/developer/P2572.txt)) to make tangent orco generation work even in the presence of valid UV layer but couldn't make it work (`CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "")` still returns -1 even after `CustomData_add_layer_named(loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");`). It not help because the rest of the generation code also assumes the same thing as `BKE_mesh_calc_loop_tangent_step_0` (that orco is only here as fallback). To me all of this is quite fragile since this means everything needs to have the same behavior and be in sync for things to never fail. The real fix is likely to fix the premise of the issue, which is that `cd_ldata` differs between eval and request. But I wouldn't know how to fix that.
Member

Based one what @fclem said and by doing some more digging I managed to reproduce the issue in a more controlled environment (and without geometry nodes, but with a small code change).

New steps to reproduce:

  1. Apply P2574. This adds a line to the array modifier (could have picked most modifiers) that removes the uv map on the mesh.
  2. Duplicate the default cube with alt+d (so that the mesh is shared).
  3. Add the array modifier to the new cube.
  4. Add a Normal Map node to the shader of the cubes and link it to the Normal input of the Principled BSDF node.
  5. Switch to material preview mode.
  6. Try to enter edit mode on the cube that has the modifier.

With the file just apply P2574 and try to enter edit mode on the selected object.

removed_uvmap_bug.blend


This may be related to the more fundamental issue that when an object with a shared mesh goes into edit mode, all objects with the same mesh will show the evaluated mesh of the object that went to edit mode:
screen_recording-2021-11-03_19.42.53.mp4

The issue had nothing to do with the Object Info node in my previous post. It was just important the geometry nodes outputs an empty mesh that does not contain the uv map. This should be perfectly legal behavior.

Based one what @fclem said and by doing some more digging I managed to reproduce the issue in a more controlled environment (and without geometry nodes, but with a small code change). New steps to reproduce: 1. Apply [P2574](https://archive.blender.org/developer/P2574.txt). This adds a line to the array modifier (could have picked most modifiers) that removes the uv map on the mesh. 2. Duplicate the default cube with alt+d (so that the mesh is shared). 3. Add the array modifier to the new cube. 4. Add a Normal Map node to the shader of the cubes and link it to the Normal input of the Principled BSDF node. 5. Switch to material preview mode. 6. Try to enter edit mode on the cube that has the modifier. With the file just apply [P2574](https://archive.blender.org/developer/P2574.txt) and try to enter edit mode on the selected object. [removed_uvmap_bug.blend](https://archive.blender.org/developer/F11700460/removed_uvmap_bug.blend) ------- This may be related to the more fundamental issue that when an object with a shared mesh goes into edit mode, all objects with the same mesh will show the evaluated mesh of the object that went to edit mode: [screen_recording-2021-11-03_19.42.53.mp4](https://archive.blender.org/developer/F11700485/screen_recording-2021-11-03_19.42.53.mp4) The issue had nothing to do with the Object Info node in my previous post. It was just important the geometry nodes outputs an empty mesh that does not contain the uv map. This should be perfectly legal behavior.

This issue was referenced by 00e4d665f4

This issue was referenced by 00e4d665f44ae63e6034b06b68729b78e9ac3131

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Clément Foucault self-assigned this 2021-11-19 19:25:30 +01:00
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 project
No Assignees
6 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#91838
No description provided.