Commit a08daed0 authored by Khushal's avatar Khushal Committed by Commit Bot

viz/test: Check for overflow in TestWebGraphicsContext3D id allocation.

The context is allocated an id which is implicitly assumed to be 2
bytes, so it can be encoded in framebuffers/texture ids and used to
verify that textures used with a context are allocated by it.

This causes overflow issues with fuzzer runs, so wrap around the id once
it reaches the max value.

R=enne@chromium.org

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I10c799520be55a310ad90a4dfdb564f805cc3ce5
Reviewed-on: https://chromium-review.googlesource.com/1040878
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarenne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555965}
parent f91c9013
...@@ -22,7 +22,17 @@ ...@@ -22,7 +22,17 @@
namespace viz { namespace viz {
static unsigned s_context_id = 1; unsigned NextContextId() {
static uint16_t s_context_id = 1;
// We need to ensure that the context_id fits in 16 bits since it is placed on
// the top 16 bits of the 32 bit identifiers (program_id, framebuffer_id,
// shader_id, etc.) generated by the context.
if (s_context_id == std::numeric_limits<uint16_t>::max()) {
LOG(ERROR) << "Exceeded max context id count; wrapping around";
s_context_id = 1;
}
return s_context_id++;
}
const GLuint TestWebGraphicsContext3D::kExternalTextureId = 1337; const GLuint TestWebGraphicsContext3D::kExternalTextureId = 1337;
...@@ -50,7 +60,7 @@ std::unique_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() { ...@@ -50,7 +60,7 @@ std::unique_ptr<TestWebGraphicsContext3D> TestWebGraphicsContext3D::Create() {
} }
TestWebGraphicsContext3D::TestWebGraphicsContext3D() TestWebGraphicsContext3D::TestWebGraphicsContext3D()
: context_id_(s_context_id++), : context_id_(NextContextId()),
times_bind_texture_succeeds_(-1), times_bind_texture_succeeds_(-1),
times_end_query_succeeds_(-1), times_end_query_succeeds_(-1),
context_lost_(false), context_lost_(false),
......
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