Suppress memory leaks detected by LSAN

In order to be able to land SwANGLE in Chromium, this cl adds
suppressions for memory leaks detected by LSAN. Some of these should
be fixed and some are intentional leaks of global variables.

This cl should allow the linux_chromium_asan_rel_ng bot to pass while
using SwANGLE and shouldn't break the win-libfuzzer-asan-rel bot.

Bug: chromium:972686
Bug: angleproject:5377
Change-Id: I7e2336aba43fcfeb95716d6c0aa05caf855134aa
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2575200
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Alexis Hétu <sugoi@chromium.org>
This commit is contained in:
Alexis Hetu 2020-12-04 14:07:24 -05:00 коммит произвёл Commit Bot
Родитель abee60f6d0
Коммит f2a154858d
5 изменённых файлов: 46 добавлений и 10 удалений

Просмотреть файл

@ -135,6 +135,10 @@ config("internal_config") {
defines += [ "ANGLE_VULKAN_DISPLAY_MODE_HEADLESS" ]
}
}
if (is_lsan) {
defines += [ "ANGLE_WITH_LSAN" ]
}
}
config("constructor_and_destructor_warnings") {

Просмотреть файл

@ -36,6 +36,7 @@ if (angle_has_build) {
is_ubsan = false
is_tsan = false
is_asan = false
is_lsan = false
build_with_chromium = false
dcheck_always_on = false
angle_use_x11 = (is_linux || is_chromeos) && !is_ggp

Просмотреть файл

@ -15,6 +15,10 @@
# include "absl/container/flat_hash_map.h"
#endif // defined(ANGLE_USE_ABSEIL)
#if defined(ANGLE_WITH_LSAN)
# include <sanitizer/lsan_interface.h>
#endif // defined(ANGLE_WITH_LSAN)
#include <climits>
#include <cstdarg>
#include <cstddef>
@ -296,6 +300,12 @@ inline bool IsLittleEndian()
UNREACHABLE(); \
ANGLE_CHECK(context, false, "Unreachable Code.", GL_INVALID_OPERATION)
#if defined(ANGLE_WITH_LSAN)
# define ANGLE_SCOPED_DISABLE_LSAN() __lsan::ScopedDisabler lsanDisabler
#else
# define ANGLE_SCOPED_DISABLE_LSAN()
#endif
// The below inlining code lifted from V8.
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
# define ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))

Просмотреть файл

@ -616,11 +616,15 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
// Gather global layer properties.
uint32_t instanceLayerCount = 0;
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceLayerProperties(&instanceLayerCount, nullptr));
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceLayerProperties(&instanceLayerCount, nullptr));
}
std::vector<VkLayerProperties> instanceLayerProps(instanceLayerCount);
if (instanceLayerCount > 0)
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceLayerProperties(&instanceLayerCount,
instanceLayerProps.data()));
}
@ -642,12 +646,16 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
// Enumerate instance extensions that are provided by the vulkan
// implementation and implicit layers.
uint32_t instanceExtensionCount = 0;
ANGLE_VK_TRY(displayVk,
vkEnumerateInstanceExtensionProperties(nullptr, &instanceExtensionCount, nullptr));
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties(
nullptr, &instanceExtensionCount, nullptr));
}
std::vector<VkExtensionProperties> instanceExtensionProps(instanceExtensionCount);
if (instanceExtensionCount > 0)
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk,
vkEnumerateInstanceExtensionProperties(nullptr, &instanceExtensionCount,
instanceExtensionProps.data()));
@ -658,12 +666,18 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
{
uint32_t previousExtensionCount = static_cast<uint32_t>(instanceExtensionProps.size());
uint32_t instanceLayerExtensionCount = 0;
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties(
layerName, &instanceLayerExtensionCount, nullptr));
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties(
layerName, &instanceLayerExtensionCount, nullptr));
}
instanceExtensionProps.resize(previousExtensionCount + instanceLayerExtensionCount);
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties(
layerName, &instanceLayerExtensionCount,
instanceExtensionProps.data() + previousExtensionCount));
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties(
layerName, &instanceLayerExtensionCount,
instanceExtensionProps.data() + previousExtensionCount));
}
}
vk::ExtensionNameList instanceExtensionNames;
@ -730,7 +744,10 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
else
{
uint32_t apiVersion = VK_API_VERSION_1_0;
ANGLE_VK_TRY(displayVk, enumerateInstanceVersion(&apiVersion));
{
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, enumerateInstanceVersion(&apiVersion));
}
if ((VK_VERSION_MAJOR(apiVersion) > 1) || (VK_VERSION_MINOR(apiVersion) >= 1))
{
// This is the highest version of core Vulkan functionality that ANGLE uses.

Просмотреть файл

@ -37,7 +37,11 @@ void SetContextToAndroidOpenGLTLSSlot(gl::Context *value)
Thread *AllocateCurrentThread()
{
gCurrentThread = new Thread();
{
// Global thread intentionally leaked
ANGLE_SCOPED_DISABLE_LSAN();
gCurrentThread = new Thread();
}
// Initialize fast TLS slot
SetContextToAndroidOpenGLTLSSlot(nullptr);