Crash on leaving local view on the shading tab. #64551

Closed
opened 2019-05-13 14:09:08 +02:00 by Daniel Santana · 17 comments

System Information
Operating system: Windows-10-10.0.17763 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.64

Blender Version
Broken: version: 2.80 (sub 62), branch: master, commit date: 2019-05-13 09:55, hash: 86650b01d8
Worked: (optional)

Short description of error
When leaving the local view on the shading tab there is a exception raise (with crash) due to a null on cache->surf_per_mat_tris
It seems surf_per_mat_tris is missing from cache.

line 5306 - draw_cache_impl_mesh.c

if (DRW_ibo_requested(cache->surf_per_mat_tris[0])) {
    mesh_create_loops_tris(rdata, cache->surf_per_mat_tris, cache->mat_len, use_hide);
}

Exact steps for others to reproduce the error
[Please describe the exact steps needed to reproduce the issue]
[Based on the default startup or an attached .blend file (as simple as possible)]

**System Information** Operating system: Windows-10-10.0.17763 64 Bits Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.64 **Blender Version** Broken: version: 2.80 (sub 62), branch: master, commit date: 2019-05-13 09:55, hash: `86650b01d8` Worked: (optional) **Short description of error** When leaving the local view on the shading tab there is a exception raise (with crash) due to a null on cache->surf_per_mat_tris It seems surf_per_mat_tris is missing from cache. line 5306 - draw_cache_impl_mesh.c ``` if (DRW_ibo_requested(cache->surf_per_mat_tris[0])) { mesh_create_loops_tris(rdata, cache->surf_per_mat_tris, cache->mat_len, use_hide); } ``` **Exact steps for others to reproduce the error** [Please describe the exact steps needed to reproduce the issue] [Based on the default startup or an attached .blend file (as simple as possible)]
Author

Added subscriber: @dgsantana

Added subscriber: @dgsantana
Author

As a workaround I added a null check to my local build just to avoid this, mostly because I don't know where the cache is populated, still "learning" my way around the blender source code.

As a workaround I added a null check to my local build just to avoid this, mostly because I don't know where the cache is populated, still "learning" my way around the blender source code.
Clément Foucault was assigned by Brecht Van Lommel 2019-05-14 00:00:03 +02:00
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Cannot reproduce here (maybe I am misunderstanding something).

  • Are we talking about View > Local View > Toggle Local View in the Shading workspace (cannot get it to crash/assert there)?
  • Or is this about the Material tab in the Properties Editor?
  • Do you have a .blend file for us where this happens?
Cannot reproduce here (maybe I am misunderstanding something). - Are we talking about `View` > `Local View` > `Toggle Local View` in the Shading workspace (cannot get it to crash/assert there)? - Or is this about the Material tab in the Properties Editor? - Do you have a .blend file for us where this happens?
Author

Unfortunately, I can't share the file. This happens after working for a while. I was doing complex baking of some meshes, in the Shading workspace. This happened twice until I added the null pointer check, one of the time was while leaving the Local View (/ Numpad), the other was whne moving from the Shading to the Layout workspace. I will make a build without my patch to see if I get any crash during the day.

Unfortunately, I can't share the file. This happens after working for a while. I was doing complex baking of some meshes, in the Shading workspace. This happened twice until I added the null pointer check, one of the time was while leaving the Local View (/ Numpad), the other was whne moving from the Shading to the Layout workspace. I will make a build without my patch to see if I get any crash during the day.
Author

And it still crashed. Left blender rendering a Diffuse bake map, and went to take care of my garden. Come back and it crashed in the same line. Going to put back the null check again.
State of blender at crash.
image.png

Stack trace:
image.png

And it still crashed. Left blender rendering a Diffuse bake map, and went to take care of my garden. Come back and it crashed in the same line. Going to put back the null check again. State of blender at crash. ![image.png](https://archive.blender.org/developer/F7036094/image.png) Stack trace: ![image.png](https://archive.blender.org/developer/F7036097/image.png)
Author

Just for the record the fix is just this:

diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 02930d38b04..0f53877a311 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -5303,7 +5303,7 @@ void DRW_mesh_batch_cache_create_requested(
   if (DRW_ibo_requested(cache->ibo.loops_tris)) {
     mesh_create_loops_tris(rdata, &cache->ibo.loops_tris, 1, use_hide);
   }
-  if (DRW_ibo_requested(cache->surf_per_mat_tris[0])) {
+  if (cache->surf_per_mat_tris && DRW_ibo_requested(cache->surf_per_mat_tris[0])) {
     mesh_create_loops_tris(rdata, cache->surf_per_mat_tris, cache->mat_len, use_hide);
   }
Just for the record the fix is just this: ``` diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 02930d38b04..0f53877a311 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -5303,7 +5303,7 @@ void DRW_mesh_batch_cache_create_requested( if (DRW_ibo_requested(cache->ibo.loops_tris)) { mesh_create_loops_tris(rdata, &cache->ibo.loops_tris, 1, use_hide); } - if (DRW_ibo_requested(cache->surf_per_mat_tris[0])) { + if (cache->surf_per_mat_tris && DRW_ibo_requested(cache->surf_per_mat_tris[0])) { mesh_create_loops_tris(rdata, cache->surf_per_mat_tris, cache->mat_len, use_hide); } ```
Member

@fclem, does this ring a bell?

@fclem, does this ring a bell?
Author

I was looking into the code where surf_per_mat_tris is inited, and there may be a corner case that could cause this, I have some objects without materials and the allocation takes in account the material count, well if the material count is zero, the new array pointer will be effectively zero in length.
This happens on draw_cache_impl_mesh.c line 2105.

I was looking into the code where surf_per_mat_tris is inited, and there may be a corner case that could cause this, I have some objects without materials and the allocation takes in account the material count, well if the material count is zero, the new array pointer will be effectively zero in length. This happens on draw_cache_impl_mesh.c line 2105.

To me, it sounds like it has to do with some VBO garbage collection we are doing.

@lichtwerk can you confirm?

To me, it sounds like it has to do with some VBO garbage collection we are doing. @lichtwerk can you confirm?
Author

And diving a little further, the MEM_lockfree_callocN makes no assumption on the request memory block asked, so if we ask a 0 block it will create one because it always has some memory used by MemHead. But I don't see a problem with this, and of course maybe its by design.

And diving a little further, the MEM_lockfree_callocN makes no assumption on the request memory block asked, so if we ask a 0 block it will create one because it always has some memory used by MemHead. But I don't see a problem with this, and of course maybe its by design.
Author

If you guys guide me a little, since I don't know the blender code (I used to create plugins for 3dsmax, houdini and maya in the past), maybe I can help track the problem. @fclem Where should I look for the garbage collection, I quite savvy on C/C++, have about 20 years of developer experience in all kinds of languages including C/C++.

If you guys guide me a little, since I don't know the blender code (I used to create plugins for 3dsmax, houdini and maya in the past), maybe I can help track the problem. @fclem Where should I look for the garbage collection, I quite savvy on C/C++, have about 20 years of developer experience in all kinds of languages including C/C++.
Author

Call stack for the latest commit (3db4284 - Fix #64601 Error division by zero in GPUVertexFormat) :

blender.exe!DRW_mesh_batch_cache_create_requested(Object * ob, Mesh * me, const ToolSettings * ts, const bool is_paint_mode, const bool use_hide) Line 5316 (d:\dev\blender\blender\source\blender\draw\intern\draw_cache_impl_mesh.c:5316)
blender.exe!drw_batch_cache_generate_requested(Object * ob) Line 4064 (d:\dev\blender\blender\source\blender\draw\intern\draw_cache.c:4064)
blender.exe!drw_engines_cache_populate(Object * ob) Line 1193 (d:\dev\blender\blender\source\blender\draw\intern\draw_manager.c:1193)
blender.exe!DRW_draw_render_loop_ex(Depsgraph * depsgraph, RenderEngineType * engine_type, ARegion * ar, View3D * v3d, GPUViewport * viewport, const bContext * evil_C) Line 1656 (d:\dev\blender\blender\source\blender\draw\intern\draw_manager.c:1656)
blender.exe!DRW_draw_view(const bContext * C) Line 1583 (d:\dev\blender\blender\source\blender\draw\intern\draw_manager.c:1583)
blender.exe!view3d_main_region_draw(const bContext * C, ARegion * ar) Line 1450 (d:\dev\blender\blender\source\blender\editors\space_view3d\view3d_draw.c:1450)
blender.exe!ED_region_do_draw(bContext * C, ARegion * ar) Line 572 (d:\dev\blender\blender\source\blender\editors\screen\area.c:572)
blender.exe!wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) Line 597 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm_draw.c:597)
blender.exe!wm_draw_window(bContext * C, wmWindow * win) Line 735 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm_draw.c:735)
blender.exe!wm_draw_update(bContext * C) Line 901 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm_draw.c:901)
blender.exe!WM_main(bContext * C) Line 425 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm.c:425)
blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 502 (d:\dev\blender\blender\source\creator\creator.c:502)
[Inline Frame] blender.exe!invoke_main() Line 78 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78)
blender.exe!__scrt_common_main_seh() Line 288 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ff8358d7974() (Unknown Source:0)
ntdll.dll!00007ff836caa271() (Unknown Source:0)
Call stack for the latest commit (3db4284 - Fix #64601 Error division by zero in GPUVertexFormat) : ``` blender.exe!DRW_mesh_batch_cache_create_requested(Object * ob, Mesh * me, const ToolSettings * ts, const bool is_paint_mode, const bool use_hide) Line 5316 (d:\dev\blender\blender\source\blender\draw\intern\draw_cache_impl_mesh.c:5316) blender.exe!drw_batch_cache_generate_requested(Object * ob) Line 4064 (d:\dev\blender\blender\source\blender\draw\intern\draw_cache.c:4064) blender.exe!drw_engines_cache_populate(Object * ob) Line 1193 (d:\dev\blender\blender\source\blender\draw\intern\draw_manager.c:1193) blender.exe!DRW_draw_render_loop_ex(Depsgraph * depsgraph, RenderEngineType * engine_type, ARegion * ar, View3D * v3d, GPUViewport * viewport, const bContext * evil_C) Line 1656 (d:\dev\blender\blender\source\blender\draw\intern\draw_manager.c:1656) blender.exe!DRW_draw_view(const bContext * C) Line 1583 (d:\dev\blender\blender\source\blender\draw\intern\draw_manager.c:1583) blender.exe!view3d_main_region_draw(const bContext * C, ARegion * ar) Line 1450 (d:\dev\blender\blender\source\blender\editors\space_view3d\view3d_draw.c:1450) blender.exe!ED_region_do_draw(bContext * C, ARegion * ar) Line 572 (d:\dev\blender\blender\source\blender\editors\screen\area.c:572) blender.exe!wm_draw_window_offscreen(bContext * C, wmWindow * win, bool stereo) Line 597 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm_draw.c:597) blender.exe!wm_draw_window(bContext * C, wmWindow * win) Line 735 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm_draw.c:735) blender.exe!wm_draw_update(bContext * C) Line 901 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm_draw.c:901) blender.exe!WM_main(bContext * C) Line 425 (d:\dev\blender\blender\source\blender\windowmanager\intern\wm.c:425) blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 502 (d:\dev\blender\blender\source\creator\creator.c:502) [Inline Frame] blender.exe!invoke_main() Line 78 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78) blender.exe!__scrt_common_main_seh() Line 288 (d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288) kernel32.dll!00007ff8358d7974() (Unknown Source:0) ntdll.dll!00007ff836caa271() (Unknown Source:0) ```

@dgsantana the garbage collection happens in DRW_batch_cache_free_old. But let me investigate this.

@dgsantana the garbage collection happens in DRW_batch_cache_free_old. But let me investigate this.
Author

It a bit weird, now it happened when zooming out on the layout workspace with Solid Texture mode. Spend an hour doing decimate on highpoly to low poly people, switching from Wire to Solid Texture, and done tons of zoom in/out. When I was about to call it a day, and zooming out to see the an overview, puff :D.
No work lost thanks to great the autoback ;).

It a bit weird, now it happened when zooming out on the layout workspace with Solid Texture mode. Spend an hour doing decimate on highpoly to low poly people, switching from Wire to Solid Texture, and done tons of zoom in/out. When I was about to call it a day, and zooming out to see the an overview, puff :D. No work lost thanks to great the autoback ;).

This issue was referenced by e9b282617a

This issue was referenced by e9b282617a93a50b9763bf5130325a0c553e165e

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
4 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#64551
No description provided.