Maniphest T80042

Crash switching to material preview due to incorrect free with Cycles
Closed, Resolved

Assigned To
Robert Guetzkow (rjg)
Authored By
Robert Guetzkow (rjg)
Aug 23 2020, 3:23 PM
Tags
  • BF Blender
  • Render & Cycles
Subscribers
Brecht Van Lommel (brecht)
Germano Cavalcante (mano-wii)
Petter Lundh (plundh)
Richard Antalik (ISS)
Robert Guetzkow (rjg)
Stefan Werner (swerner)

Description

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

  1. Set the render engine to Cycles.
  2. Switch viewport shading to Rendered.
  3. Open the material properties and the preview panel within.
  4. Switch to the shader ball preview shape and wait until it is properly displayed.
  5. 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]

Revisions and Commits

rC Cycles
D8772
rB Blender
D8772
D8772

Event Timeline

Robert Guetzkow (rjg) renamed this task from Crash material preview due to incorrect free with Cycles to Crash switching to material preview due to incorrect free with Cycles.Aug 23 2020, 3:23 PM
Robert Guetzkow (rjg) created this task.
Robert Guetzkow (rjg) added a project: Render & Cycles.
Robert Guetzkow (rjg) updated the task description.Aug 23 2020, 3:32 PM
Robert Guetzkow (rjg) updated the task description.Aug 23 2020, 3:44 PM
Petter Lundh (plundh) added a subscriber: Petter Lundh (plundh).Aug 23 2020, 9:04 PM
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).Aug 25 2020, 5:33 PM

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:

Robert Guetzkow (rjg) added a comment.EditedAug 25 2020, 6:52 PM

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.

Germano Cavalcante (mano-wii) added a comment.Aug 25 2020, 9:49 PM

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

Robert Guetzkow (rjg) added a comment.Aug 25 2020, 10:11 PM

@Germano Cavalcante (mano-wii) Did you check with the same commit or latest master?

Germano Cavalcante (mano-wii) added a comment.Aug 25 2020, 11:54 PM

Tested with the latest master

Richard Antalik (ISS) added a subscriber: Richard Antalik (ISS).Aug 26 2020, 6:13 AM

Also can't repro on master

Robert Guetzkow (rjg) added a comment.Aug 26 2020, 10:24 AM

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.

Brecht Van Lommel (brecht) added subscribers: Stefan Werner (swerner), Brecht Van Lommel (brecht).Aug 26 2020, 3:07 PM

@Stefan Werner (swerner), 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 (swerner) added a comment.Aug 31 2020, 1:31 PM

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.

Robert Guetzkow (rjg) changed the task status from Needs Triage to Confirmed.EditedAug 31 2020, 1:40 PM
Robert Guetzkow (rjg) triaged this task as High priority.

@Stefan Werner (swerner) @Brecht Van Lommel (brecht) I'm marking this as confirmed with high priority then, if that's ok?

Stefan Werner (swerner) added a commit: rB009971ba7adc: Cycles: Separate Embree device for each CPU Device..Sep 1 2020, 9:57 PM
Robert Guetzkow (rjg) closed this task as Resolved.Sep 2 2020, 12:43 AM
Robert Guetzkow (rjg) claimed this task.

@Stefan Werner (swerner) Works like a charm. Thank you for the bug fix.

Jeroen Bakker (jbakker) added a commit: rB918ef5f8352a: Cycles: Separate Embree device for each CPU Device..Sep 21 2020, 9:58 AM
Stefan Werner (swerner) added a commit: rC95c087c47bb2: Separate embree device for each cpu device.Mar 1 2021, 2:17 AM