Commit f2a15485 by Alexis Hetu Committed by Commit Bot

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/+/2575200Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Alexis Hétu <sugoi@chromium.org>
parent abee60f6
...@@ -135,6 +135,10 @@ config("internal_config") { ...@@ -135,6 +135,10 @@ config("internal_config") {
defines += [ "ANGLE_VULKAN_DISPLAY_MODE_HEADLESS" ] defines += [ "ANGLE_VULKAN_DISPLAY_MODE_HEADLESS" ]
} }
} }
if (is_lsan) {
defines += [ "ANGLE_WITH_LSAN" ]
}
} }
config("constructor_and_destructor_warnings") { config("constructor_and_destructor_warnings") {
......
...@@ -36,6 +36,7 @@ if (angle_has_build) { ...@@ -36,6 +36,7 @@ if (angle_has_build) {
is_ubsan = false is_ubsan = false
is_tsan = false is_tsan = false
is_asan = false is_asan = false
is_lsan = false
build_with_chromium = false build_with_chromium = false
dcheck_always_on = false dcheck_always_on = false
angle_use_x11 = (is_linux || is_chromeos) && !is_ggp angle_use_x11 = (is_linux || is_chromeos) && !is_ggp
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
# include "absl/container/flat_hash_map.h" # include "absl/container/flat_hash_map.h"
#endif // defined(ANGLE_USE_ABSEIL) #endif // defined(ANGLE_USE_ABSEIL)
#if defined(ANGLE_WITH_LSAN)
# include <sanitizer/lsan_interface.h>
#endif // defined(ANGLE_WITH_LSAN)
#include <climits> #include <climits>
#include <cstdarg> #include <cstdarg>
#include <cstddef> #include <cstddef>
...@@ -296,6 +300,12 @@ inline bool IsLittleEndian() ...@@ -296,6 +300,12 @@ inline bool IsLittleEndian()
UNREACHABLE(); \ UNREACHABLE(); \
ANGLE_CHECK(context, false, "Unreachable Code.", GL_INVALID_OPERATION) 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. // The below inlining code lifted from V8.
#if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute)) #if defined(__clang__) || (defined(__GNUC__) && defined(__has_attribute))
# define ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) # define ANGLE_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline))
......
...@@ -616,11 +616,15 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -616,11 +616,15 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
// Gather global layer properties. // Gather global layer properties.
uint32_t instanceLayerCount = 0; 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); std::vector<VkLayerProperties> instanceLayerProps(instanceLayerCount);
if (instanceLayerCount > 0) if (instanceLayerCount > 0)
{ {
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceLayerProperties(&instanceLayerCount, ANGLE_VK_TRY(displayVk, vkEnumerateInstanceLayerProperties(&instanceLayerCount,
instanceLayerProps.data())); instanceLayerProps.data()));
} }
...@@ -642,12 +646,16 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -642,12 +646,16 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
// Enumerate instance extensions that are provided by the vulkan // Enumerate instance extensions that are provided by the vulkan
// implementation and implicit layers. // implementation and implicit layers.
uint32_t instanceExtensionCount = 0; 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); std::vector<VkExtensionProperties> instanceExtensionProps(instanceExtensionCount);
if (instanceExtensionCount > 0) if (instanceExtensionCount > 0)
{ {
ANGLE_SCOPED_DISABLE_LSAN();
ANGLE_VK_TRY(displayVk, ANGLE_VK_TRY(displayVk,
vkEnumerateInstanceExtensionProperties(nullptr, &instanceExtensionCount, vkEnumerateInstanceExtensionProperties(nullptr, &instanceExtensionCount,
instanceExtensionProps.data())); instanceExtensionProps.data()));
...@@ -658,12 +666,18 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -658,12 +666,18 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
{ {
uint32_t previousExtensionCount = static_cast<uint32_t>(instanceExtensionProps.size()); uint32_t previousExtensionCount = static_cast<uint32_t>(instanceExtensionProps.size());
uint32_t instanceLayerExtensionCount = 0; 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); instanceExtensionProps.resize(previousExtensionCount + instanceLayerExtensionCount);
ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties( {
layerName, &instanceLayerExtensionCount, ANGLE_SCOPED_DISABLE_LSAN();
instanceExtensionProps.data() + previousExtensionCount)); ANGLE_VK_TRY(displayVk, vkEnumerateInstanceExtensionProperties(
layerName, &instanceLayerExtensionCount,
instanceExtensionProps.data() + previousExtensionCount));
}
} }
vk::ExtensionNameList instanceExtensionNames; vk::ExtensionNameList instanceExtensionNames;
...@@ -730,7 +744,10 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -730,7 +744,10 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
else else
{ {
uint32_t apiVersion = VK_API_VERSION_1_0; 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)) if ((VK_VERSION_MAJOR(apiVersion) > 1) || (VK_VERSION_MINOR(apiVersion) >= 1))
{ {
// This is the highest version of core Vulkan functionality that ANGLE uses. // This is the highest version of core Vulkan functionality that ANGLE uses.
......
...@@ -37,7 +37,11 @@ void SetContextToAndroidOpenGLTLSSlot(gl::Context *value) ...@@ -37,7 +37,11 @@ void SetContextToAndroidOpenGLTLSSlot(gl::Context *value)
Thread *AllocateCurrentThread() Thread *AllocateCurrentThread()
{ {
gCurrentThread = new Thread(); {
// Global thread intentionally leaked
ANGLE_SCOPED_DISABLE_LSAN();
gCurrentThread = new Thread();
}
// Initialize fast TLS slot // Initialize fast TLS slot
SetContextToAndroidOpenGLTLSSlot(nullptr); SetContextToAndroidOpenGLTLSSlot(nullptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment