Hash :
0c7c14eb
Author :
Date :
2024-11-22T10:31:45
Capture: add a sanity check to InitializeReplay4 args In the case on the bug we were getting maxProgramPipeline = 1684105299 due to an unitialized memory read, which then led to Replay OOM crash as it allocates an array of this size. This is difficult to diagnose in Replay as OOM leads to SIGKILL which cannot be trapped so we can't have a backtrace. Adding a sanity check during capture. Fix the other tests where we hit this (https://anglebug.com/380296979#comment6) One of them visible on red tests on a previous patchset in this CL: https://ci.chromium.org/ui/p/angle/builders/try/linux-trace/9871/overview https://ci.chromium.org/ui/p/angle/builders/try/win-trace/10795/overview Bug: angleproject:380296979 Change-Id: I2879c1947742a9751a122545c8ba8da23ab243cb Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6042185 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Roman Lavrov <romanl@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
namespace
{
constexpr char kVS[] = R"(attribute vec4 aTest;
attribute vec2 aPosition;
varying vec4 vTest;
void main()
{
vTest = aTest;
gl_Position = vec4(aPosition, 0.0, 1.0);
gl_PointSize = 1.0;
})";
constexpr char kFS[] = R"(precision mediump float;
varying vec4 vTest;
void main()
{
gl_FragColor = vTest;
})";
} // namespace
class PBOExtensionTest : public ANGLETest<>
{
protected:
PBOExtensionTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
void testSetUp() override
{
if (IsGLExtensionEnabled("NV_pixel_buffer_object"))
{
glGenBuffers(1, &mPBO);
glBindBuffer(GL_PIXEL_PACK_BUFFER, mPBO);
glBufferData(GL_PIXEL_PACK_BUFFER, 4 * getWindowWidth() * getWindowHeight(), nullptr,
GL_STATIC_DRAW);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
mProgram = CompileProgram(kVS, kFS);
glGenBuffers(1, &mPositionVBO);
glBindBuffer(GL_ARRAY_BUFFER, mPositionVBO);
glBufferData(GL_ARRAY_BUFFER, 128, nullptr, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
ASSERT_GL_NO_ERROR();
}
void testTearDown() override
{
glDeleteBuffers(1, &mPBO);
glDeleteProgram(mProgram);
}
GLuint mPBO = 0;
GLuint mProgram = 0;
GLuint mPositionVBO = 0;
};
TEST_P(PBOExtensionTest, PBOWithOtherTarget)
{
if (IsGLExtensionEnabled("NV_pixel_buffer_object"))
{
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
glBindBuffer(GL_PIXEL_PACK_BUFFER, mPBO);
glReadPixels(0, 0, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, mPBO);
void *mappedPtr = glMapBufferRangeEXT(GL_ARRAY_BUFFER, 0, 32, GL_MAP_READ_BIT);
unsigned char *dataPtr = static_cast<unsigned char *>(mappedPtr);
EXPECT_GL_NO_ERROR();
EXPECT_EQ(255, dataPtr[0]);
EXPECT_EQ(0, dataPtr[1]);
EXPECT_EQ(0, dataPtr[2]);
EXPECT_EQ(255, dataPtr[3]);
glUnmapBufferOES(GL_ARRAY_BUFFER);
}
EXPECT_GL_NO_ERROR();
}
TEST_P(PBOExtensionTest, PBOWithExistingData)
{
if (IsGLExtensionEnabled("NV_pixel_buffer_object"))
{
// Clear backbuffer to red
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
// Read 16x16 region from red backbuffer to PBO
glBindBuffer(GL_PIXEL_PACK_BUFFER, mPBO);
glReadPixels(0, 0, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// Clear backbuffer to green
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
// Read 16x16 region from green backbuffer to PBO at offset 16
glReadPixels(0, 0, 16, 16, GL_RGBA, GL_UNSIGNED_BYTE, reinterpret_cast<void *>(16));
void *mappedPtr = glMapBufferRangeEXT(GL_PIXEL_PACK_BUFFER, 0, 32, GL_MAP_READ_BIT);
unsigned char *dataPtr = static_cast<unsigned char *>(mappedPtr);
EXPECT_GL_NO_ERROR();
// Test pixel 0 is red (existing data)
EXPECT_EQ(255, dataPtr[0]);
EXPECT_EQ(0, dataPtr[1]);
EXPECT_EQ(0, dataPtr[2]);
EXPECT_EQ(255, dataPtr[3]);
// Test pixel 16 is green (new data)
EXPECT_EQ(0, dataPtr[16 * 4 + 0]);
EXPECT_EQ(255, dataPtr[16 * 4 + 1]);
EXPECT_EQ(0, dataPtr[16 * 4 + 2]);
EXPECT_EQ(255, dataPtr[16 * 4 + 3]);
glUnmapBufferOES(GL_PIXEL_PACK_BUFFER);
}
EXPECT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(PBOExtensionTest);