The Cycles cpu/device.cpp `device_cpu_capabilities()` function used to
fill out a string of supported CPU capabilities separated with spaces,
with some trailing-space cleaning logic at the end of the function.
However, if no check succeeded, and especially after commit 2bf6d0fd71
which left only one check and removed the need for removing trailing
spaces, the check would run against an empty string, resulting in an
unsigned 0 - 1 operation which would then cause an out of bound access
catched by ASan.
Fixed by removing the now superflous trailing space cleaning logic and
simplifying to a direct return.
Pull Request: https://projects.blender.org/blender/blender/pulls/148227
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "device/cpu/device.h"
|
|
#include "device/cpu/device_impl.h"
|
|
#include "device/device.h"
|
|
|
|
/* Used for `info.denoisers`. */
|
|
/* TODO(sergey): The denoisers are probably to be moved completely out of the device into their
|
|
* own class. But until then keep API consistent with how it used to work before. */
|
|
#include "util/guiding.h"
|
|
#include "util/openimagedenoise.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
unique_ptr<Device> device_cpu_create(const DeviceInfo &info,
|
|
Stats &stats,
|
|
Profiler &profiler,
|
|
bool headless)
|
|
{
|
|
return make_unique<CPUDevice>(info, stats, profiler, headless);
|
|
}
|
|
|
|
void device_cpu_info(vector<DeviceInfo> &devices)
|
|
{
|
|
DeviceInfo info;
|
|
|
|
info.type = DEVICE_CPU;
|
|
info.description = system_cpu_brand_string();
|
|
info.id = "CPU";
|
|
info.num = 0;
|
|
info.has_osl = true;
|
|
info.has_nanovdb = true;
|
|
info.has_profiling = true;
|
|
if (guiding_supported()) {
|
|
info.has_guiding = true;
|
|
}
|
|
else {
|
|
info.has_guiding = false;
|
|
}
|
|
if (openimagedenoise_supported()) {
|
|
info.denoisers |= DENOISER_OPENIMAGEDENOISE;
|
|
}
|
|
|
|
devices.insert(devices.begin(), info);
|
|
}
|
|
|
|
string device_cpu_capabilities()
|
|
{
|
|
return system_cpu_support_avx2() ? "AVX2" : "";
|
|
}
|
|
|
|
CCL_NAMESPACE_END
|