Crash switching to material preview due to incorrect free with Cycles #80042

Closed
opened 2020-08-23 15:23:05 +02:00 by Robert Guetzkow · 21 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.30

Blender Version
Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-08-23 11:17, hash: e74ba9e09e
Worked: (newest version of Blender that worked as expected)

Short description of error
Blender crashes when switching the viewport shading to Material Preview when the material preview in the material properties isn't properly rendered yet.
This was tested on a debug build.

Exact steps for others to reproduce the error

  • Set the render engine to Cycles.
  • Switch viewport shading to Rendered.
  • Open the material properties and the preview panel within.
  • Switch to the shader ball preview shape and wait until it is properly displayed.

Switch to another preview shape like the sphere and before it displays the change, switch the viewport shading to Material Preview.

ccl::Stats::mem_free(unsigned __int64 size) Line 44	C++
ccl::rtc_memory_monitor_func(void * userPtr, const __int64 bytes, const bool __formal) Line 267	C++
[External Code]	
ccl::BVHEmbree::destroy(RTCSceneTy * scene) Line 391	C++
ccl::GeometryManager::device_free(ccl::Device * device, ccl::DeviceScene * dscene) Line 1418	C++
ccl::Scene::free_memory(bool final) Line 161	C++
ccl::Scene::~Scene() Line 131	C++
[External Code]	
ccl::Session::~Session() Line 132	C++
[External Code]	
ccl::BlenderSession::free_session() Line 262	C++
ccl::BlenderSession::~BlenderSession() Line 116	C++
[External Code]	
ccl::free_func(_object * __formal, _object * value) Line 273	C++
[External Code]	
BPY_DECREF_RNA_INVALIDATE(void * pyob_ptr) Line 458	C
RE_engine_free(RenderEngine * engine) Line 151	C
RE_engine_render(Render * re, int do_all) Line 918	C
do_render_3d(Render * re) Line 1137	C
RE_PreviewRender(Render * re, Main * bmain, Scene * sce) Line 2685	C
shader_preview_render(ShaderPreview * sp, ID * id, int split, int first) Line 900	C
shader_preview_startjob(void * customdata, short * stop, short * do_update) Line 938	C
common_preview_startjob(void * customdata, short * stop, short * do_update, float * UNUSED_progress) Line 1181	C
do_job_thread(void * job_v) Line 396	C
tslot_thread_start(void * tslot_p) Line 227	C++
[External Code]
**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 436.30 **Blender Version** Broken: version: 2.91.0 Alpha, branch: master, commit date: 2020-08-23 11:17, hash: `e74ba9e09e` Worked: (newest version of Blender that worked as expected) **Short description of error** Blender crashes when switching the viewport shading to *Material Preview* when the material preview in the material properties isn't properly rendered yet. This was tested on a debug build. **Exact steps for others to reproduce the error** - Set the render engine to *Cycles*. - Switch viewport shading to *Rendered*. - Open the material properties and the preview panel within. - Switch to the *shader ball* preview shape and wait until it is properly displayed. # Switch to another preview shape like the *sphere* and before it displays the change, switch the viewport shading to *Material Preview*. ``` ccl::Stats::mem_free(unsigned __int64 size) Line 44 C++ ccl::rtc_memory_monitor_func(void * userPtr, const __int64 bytes, const bool __formal) Line 267 C++ [External Code] ccl::BVHEmbree::destroy(RTCSceneTy * scene) Line 391 C++ ccl::GeometryManager::device_free(ccl::Device * device, ccl::DeviceScene * dscene) Line 1418 C++ ccl::Scene::free_memory(bool final) Line 161 C++ ccl::Scene::~Scene() Line 131 C++ [External Code] ccl::Session::~Session() Line 132 C++ [External Code] ccl::BlenderSession::free_session() Line 262 C++ ccl::BlenderSession::~BlenderSession() Line 116 C++ [External Code] ccl::free_func(_object * __formal, _object * value) Line 273 C++ [External Code] BPY_DECREF_RNA_INVALIDATE(void * pyob_ptr) Line 458 C RE_engine_free(RenderEngine * engine) Line 151 C RE_engine_render(Render * re, int do_all) Line 918 C do_render_3d(Render * re) Line 1137 C RE_PreviewRender(Render * re, Main * bmain, Scene * sce) Line 2685 C shader_preview_render(ShaderPreview * sp, ID * id, int split, int first) Line 900 C shader_preview_startjob(void * customdata, short * stop, short * do_update) Line 938 C common_preview_startjob(void * customdata, short * stop, short * do_update, float * UNUSED_progress) Line 1181 C do_job_thread(void * job_v) Line 396 C tslot_thread_start(void * tslot_p) Line 227 C++ [External Code] ```
Author
Member

Added subscriber: @rjg

Added subscriber: @rjg
Robert Guetzkow changed title from Crash material preview due to incorrect free with Cycles to Crash switching to material preview due to incorrect free with Cycles 2020-08-23 15:24:40 +02:00

Added subscriber: @PetterLundh

Added subscriber: @PetterLundh

Added subscriber: @mano-wii

Added subscriber: @mano-wii

When you say "before it displays the change", is it before the samples are complete or before the image appears?
I cannot reproduce the problem:
preview_crash.gif

When you say "before it displays the change", is it before the samples are complete or before the image appears? I cannot reproduce the problem: ![preview_crash.gif](https://archive.blender.org/developer/F8810667/preview_crash.gif)
Author
Member

Before the image appears. That's at least how I could quite reliably reproduce it on my system. I was using a debug build and the rendering was therefore slower, which allowed me to do this.

I'm not sure if this is relevant, but I've also just used the default material.

Before the image appears. That's at least how I could quite reliably reproduce it on my system. I was using a debug build and the rendering was therefore slower, which allowed me to do this. I'm not sure if this is relevant, but I've also just used the default material.

I also can't reproduce the problem in Debug Build.


Operating system: Windows-10-10.0.18941 64 Bits
Graphics card: Radeon (TM) RX 480 Graphics ATI Technologies Inc. 4.5.13596 Core Profile Context 20.10.19.02 27.20.1019.2002

I also can't reproduce the problem in Debug Build. ---- **Operating system:** Windows-10-10.0.18941 64 Bits **Graphics card:** Radeon (TM) RX 480 Graphics ATI Technologies Inc. 4.5.13596 Core Profile Context 20.10.19.02 27.20.1019.2002
Author
Member

@mano-wii Did you check with the same commit or latest master?

@mano-wii Did you check with the same commit or latest master?

Tested with the latest master

Tested with the latest master

Added subscriber: @iss

Added subscriber: @iss

Also can't repro on master

Also can't repro on master
Author
Member

This is still reproducible for me with the latest master and the same steps.

I can try to investigate the cause, but I'm currently quite busy so this will have to wait to until the weekend.

This is still reproducible for me with the latest master and the same steps. I can try to investigate the cause, but I'm currently quite busy so this will have to wait to until the weekend.

Added subscribers: @Stefan_Werner, @brecht

Added subscribers: @Stefan_Werner, @brecht

@Stefan_Werner, I guess there is some issue in the Embree freeing code, maybe in cases where rendering is aborted before the BVH is built?

@Stefan_Werner, I guess there is some issue in the Embree freeing code, maybe in cases where rendering is aborted before the BVH is built?
Member

It won't crash every time, but this crash is reproducible:
The cause is that all Cycles instances share the same Embree device, but use separate ccl::Stats objects. Embree's memory callback can then end up contributing to the wrong Stats object, or worst case, run into an invalid pointer.

It won't crash every time, but this crash is reproducible: The cause is that all Cycles instances share the same Embree device, but use separate ccl::Stats objects. Embree's memory callback can then end up contributing to the wrong Stats object, or worst case, run into an invalid pointer.
Author
Member

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

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

@Stefan_Werner @brecht I'm marking this as confirmed with high priority then, if that's ok?

@Stefan_Werner @brecht I'm marking this as confirmed with high priority then, if that's ok?

This issue was referenced by blender/cycles@95c087c47b

This issue was referenced by blender/cycles@95c087c47bb2721a0e19bcff0b402c232f153332

This issue was referenced by 918ef5f835

This issue was referenced by 918ef5f8352a209fba9846effe584bec9c97b1f6

This issue was referenced by 009971ba7a

This issue was referenced by 009971ba7adc9603b90e9bf99b6b6d53eeae6c3a
Author
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Robert Guetzkow self-assigned this 2020-09-02 00:43:56 +02:00
Author
Member

@Stefan_Werner Works like a charm. Thank you for the bug fix.

@Stefan_Werner Works like a charm. Thank you for the bug fix.
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
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#80042
No description provided.