Maniphest T91838

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

Assigned To
Clément Foucault (fclem)
Authored By
Lino Thomas (linolafett)
Sep 30 2021, 2:33 PM
Tags
  • BF Blender
  • Nodes & Physics
  • Geometry Nodes
  • EEVEE & Viewport
Subscribers
Clément Foucault (fclem)
Hans Goudey (HooglyBoogly)
Jacques Lucke (JacquesLucke)
Lino Thomas (linolafett)
Richard Antalik (ISS)

Description

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


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 :)

Revisions and Commits

rB Blender

Event Timeline

Lino Thomas (linolafett) created this task.Sep 30 2021, 2:33 PM
Richard Antalik (ISS) changed the task status from Needs Triage to Confirmed.Sep 30 2021, 4:12 PM
Richard Antalik (ISS) added projects: Nodes & Physics, Geometry Nodes.
Richard Antalik (ISS) added a subscriber: Richard Antalik (ISS).

Can confirm crash on NULL dereference

1 blender.exe!GPU_vertformat_safe_attr_name(const char * attr_name, char * r_safe_name, unsigned int UNUSED_max_len) Line 279 C++
2> blender.exe!blender::draw::extract_tan_ex_init(const MeshRenderData * mr, MeshBatchCache * cache, GPUVertBuf * vbo, const bool do_hq) Line 147 C++
3 blender.exe!blender::draw::extract_tan_init(const MeshRenderData * mr, MeshBatchCache * cache, void * buf, void * UNUSED_tls_data) Line 220 C++
4 blender.exe!blender::draw::extract_init(const MeshRenderData * mr, MeshBatchCache * cache, blender::draw::ExtractorRunDatas & extractors, MeshBufferList * mbuflist, void * data_stack) Line 220 C++
5 blender.exe!blender::draw::extract_task_range_run(void * taskdata) Line 454 C++
6 blender.exe!TaskNode::run(const tbb::flow::interface11::continue_msg UNUSED_input) Line 95 C++
7 blender.exe!TaskNode::<lambda>(const tbb::flow::interface11::continue_msg input) Line 70 C++
8 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++
9 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++
10 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++
11 [External Code]
12 blender.exe!tbb::task::wait_for_all() Line 821 C++
13 blender.exe!tbb::flow::interface10::graph::wait_functor::operator()() Line 252 C++
14 blender.exe!tbb::interface7::internal::delegated_function<tbb::flow::interface10::graph::wait_functor const ,void>::operator()() Line 97 C++
15 [External Code]
16 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++
17 blender.exe!tbb::interface7::task_arena::execute<tbb::flow::interface10::graph::wait_functor>(const tbb::flow::interface10::graph::wait_functor & f) Line 434 C++
18 blender.exe!tbb::flow::interface10::graph::wait_for_all() Line 347 C++
19 blender.exe!BLI_task_graph_work_and_wait(TaskGraph * task_graph) Line 129 C++
20 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
21 blender.exe!drw_batch_cache_generate_requested(Object * ob) Line 3435 C
22 blender.exe!drw_engines_cache_populate(Object * ob) Line 1061 C
23 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
24 blender.exe!DRW_draw_view(const bContext * C) Line 1489 C
25 blender.exe!view3d_draw_view(const bContext * C, ARegion * region) Line 1566 C
26 blender.exe!view3d_main_region_draw(const bContext * C, ARegion * region) Line 1589 C
27 blender.exe!ED_region_do_draw(bContext * C, ARegion * region) Line 569 C
28 blender.exe!wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) Line 729 C
29 blender.exe!wm_draw_window(bContext * C, wmWindow * win) Line 880 C
30 blender.exe!wm_draw_update(bContext * C) Line 1079 C
31 blender.exe!WM_main(bContext * C) Line 654 C
32 blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 562 C
33 [External Code]

Hans Goudey (HooglyBoogly) triaged this task as High priority.Nov 1 2021, 9:38 PM
Hans Goudey (HooglyBoogly) changed the subtype of this task from "Report" to "Bug".
Hans Goudey (HooglyBoogly) added a project: EEVEE & Viewport.
Hans Goudey (HooglyBoogly) added a subscriber: Hans Goudey (HooglyBoogly).

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.

Jacques Lucke (JacquesLucke) added a subscriber: Jacques Lucke (JacquesLucke).EditedNov 2 2021, 7:14 PM

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.

[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.

Clément Foucault (fclem) added a subscriber: Clément Foucault (fclem).Nov 3 2021, 5:05 PM

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.

Jacques Lucke (JacquesLucke) added a comment.Nov 3 2021, 7:44 PM

Based one what @Clément Foucault (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.


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:

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.

Jacques Lucke (JacquesLucke) moved this task from Backlog/Bugs to Next Release Targets on the Geometry Nodes board.Nov 9 2021, 5:17 PM
Jacques Lucke (JacquesLucke) mentioned this in P2605 Masterwork From Distant Lands.Nov 19 2021, 3:24 PM
Clément Foucault (fclem) closed this task as Resolved by committing rB00e4d665f44a: Fix T91838 Crash when toggling edit mode on object with geometry node modifier….Nov 19 2021, 7:25 PM
Clément Foucault (fclem) claimed this task.
Clément Foucault (fclem) added a commit: rB00e4d665f44a: Fix T91838 Crash when toggling edit mode on object with geometry node modifier….