Suppress a failure with new (std::nothrow) on Mac ARM64.
This happens when trying to allocate the backing storage for an error
buffer when the allocation would cause an OOM.
new (std::nothrow) doesn't work on Mac ARM64. The code in libc++ that's
compiled into dawn_unittests seems correct, but macOS's libunwind
returns "end of stack" when trying to unwind.
Bug: dawn:1506
Change-Id: Ibc5d7251ea7a411b0e3cc91646a059270d965a90
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98122
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/tests/unittests/validation/BufferValidationTests.cpp b/src/dawn/tests/unittests/validation/BufferValidationTests.cpp
index 11b42be..af95b82 100644
--- a/src/dawn/tests/unittests/validation/BufferValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/BufferValidationTests.cpp
@@ -15,6 +15,7 @@
#include <limits>
#include <memory>
+#include "dawn/common/Platform.h"
#include "dawn/tests/unittests/validation/ValidationTest.h"
#include "gmock/gmock.h"
@@ -802,12 +803,6 @@
// Test valid cases to call GetMappedRange on an error buffer.
TEST_F(BufferValidationTest, GetMappedRange_OnErrorBuffer) {
- wgpu::BufferDescriptor desc;
- desc.size = 4;
- desc.usage = wgpu::BufferUsage::Storage | wgpu::BufferUsage::MapRead;
-
- uint64_t kStupidLarge = uint64_t(1) << uint64_t(63);
-
// GetMappedRange after mappedAtCreation a zero-sized buffer returns a non-nullptr.
// This is to check we don't do a malloc(0).
{
@@ -828,17 +823,23 @@
ASSERT_NE(buffer.GetConstMappedRange(), nullptr);
ASSERT_EQ(buffer.GetConstMappedRange(), buffer.GetMappedRange());
}
+}
+
+// Test valid cases to call GetMappedRange on an error buffer that's also OOM.
+TEST_F(BufferValidationTest, GetMappedRange_OnErrorBuffer_OOM) {
+ // TODO(crbug.com/dawn/1506): new (std::nothrow) crashes on OOM on Mac ARM64 because libunwind
+ // doesn't see the previous catchall try-catch.
+ DAWN_SKIP_TEST_IF(DAWN_PLATFORM_IS(MACOS) && DAWN_PLATFORM_IS(ARM64));
+
+ uint64_t kStupidLarge = uint64_t(1) << uint64_t(63);
+
+ wgpu::Buffer buffer;
+ ASSERT_DEVICE_ERROR(buffer = BufferMappedAtCreation(
+ kStupidLarge, wgpu::BufferUsage::Storage | wgpu::BufferUsage::MapRead));
// GetMappedRange after mappedAtCreation OOM case returns nullptr.
- {
- wgpu::Buffer buffer;
- ASSERT_DEVICE_ERROR(
- buffer = BufferMappedAtCreation(
- kStupidLarge, wgpu::BufferUsage::Storage | wgpu::BufferUsage::MapRead));
-
- ASSERT_EQ(buffer.GetConstMappedRange(), nullptr);
- ASSERT_EQ(buffer.GetConstMappedRange(), buffer.GetMappedRange());
- }
+ ASSERT_EQ(buffer.GetConstMappedRange(), nullptr);
+ ASSERT_EQ(buffer.GetConstMappedRange(), buffer.GetMappedRange());
}
// Test validation of the GetMappedRange parameters