Fix #148071: EEVEE: Crash when using Sky Texture + Multi-scattering
Caused by some tricky use after-free / stack corruption. This affect both Cycles and EEVEE. The `sms` local variable is getting dereferenced by `get_inscattering` inside the threaded for loop but is passed by copy to the lambda expression. This makes its lifetime ill-defined in a multithreaded context. I am not fully sure about the rules at play here so maybe my understanding is wrong. But removing the call to `get_inscattering` avoids the crash. Note that `SkyMultipleScattering` is also very big (it contains the whole LUT). So copying it might have caused stack overflow. But that should trigger a system interupt. Passing everything by references fixes the issue. This seems to be safe since all as the other local variables are `const` anyway. Also the loop doesn't seem to modify the one that aren't. Pull Request: https://projects.blender.org/blender/blender/pulls/148260
This commit is contained in:
committed by
Clément Foucault
parent
861a174a82
commit
632bd741f7
@@ -319,7 +319,7 @@ void SKY_multiple_scattering_precompute_texture(float *pixels,
|
|||||||
const float3 sun_dir = sun_direction(sun_zenith_cos_angle);
|
const float3 sun_dir = sun_direction(sun_zenith_cos_angle);
|
||||||
const int rows_per_task = std::max(1024 / width, 1);
|
const int rows_per_task = std::max(1024 / width, 1);
|
||||||
|
|
||||||
SKY_parallel_for(0, height, rows_per_task, [=](const size_t begin, const size_t end) {
|
SKY_parallel_for(0, height, rows_per_task, [&](const size_t begin, const size_t end) {
|
||||||
for (int y = begin; y < end; y++) {
|
for (int y = begin; y < end; y++) {
|
||||||
float *pixel_row = pixels + (y * width * stride);
|
float *pixel_row = pixels + (y * width * stride);
|
||||||
for (int x = 0; x < half_width; x++) {
|
for (int x = 0; x < half_width; x++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user