RenderKit / embree

Embree ray tracing kernels repository.
Apache License 2.0
2.32k stars 383 forks source link

global g_arena leading to crashes in Blender 3.6 #453

Closed ph0b closed 12 months ago

ph0b commented 12 months ago

This global pointer to a task arena : https://github.com/embree/embree/blob/0fcb306c9176221219dd15e27fe0527ed334948f/kernels/rthwif/rtbuild/rtbuild.cpp#L219 gets reset when a device gets deleted, leading to crashes in Blender in the following scenario:

  1. users goes into render preview mode -> an embree device is created and kept alive.
  2. user triggers an offline renders -> a second embree device is created and deleted when render is done, https://github.com/embree/embree/blob/0fcb306c9176221219dd15e27fe0527ed334948f/kernels/rthwif/rtbuild/rtbuild.cpp#L219 called from its destructor, deletes the task arena
  3. user modifies anything in the scene being previewed -> BVH gets rebuilt using g_arena which is now nullptr, so https://github.com/embree/embree/blob/0fcb306c9176221219dd15e27fe0527ed334948f/kernels/rthwif/rtbuild/rtbuild.cpp#L743 triggers a read access violation embree::g_arena._Mypair._Myval2 was nullptr.
svenwoop commented 12 months ago

This task_arena got already changed in latest Embree to just be a static variable, thus it is no longer destroyed dynamically at all. Please check with latest Embree, issue should be gone.

ph0b commented 12 months ago

Great! It may be done with your internal dev branch but that's not visible here, can you backport this change to 4.1 and/or make a new release soon ?

svenwoop commented 12 months ago

We are just 2 weeks away of a new release, likely happening around 20th July.

ph0b commented 12 months ago

Ok. I confirm switching from a pointer to a variable and getting rid of the dynamic destruction fixes the crash. Opened https://projects.blender.org/blender/blender/pulls/109966 on the Blender side.