Commit 338abb46 by JiangYizhou Committed by Commit Bot

Fix invalid heap exception in angle

Running angle deqp test case, an invalid heap exception is thrown in angle on both linux and windows platforms. If build a nonsequential heap, and then erase any node of the heap, the heap is no longer valid. If using std::push_heap or std::pop_heap method next, this exception will be thrown out. So we should use std::make_heap after modifying the heap. TEST=angle_deqp_gles2_tests TEST=angle_deqp_gles3_tests TEST=HandleAllocatorTest.ReserveAfterReleaseBug BUG=angleproject:2326 Change-Id: I123fc81b3365c93081d0042c69b4e5114956fe0d Reviewed-on: https://chromium-review.googlesource.com/892961Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 14cb42c0
......@@ -114,6 +114,7 @@ void HandleAllocator::reserve(GLuint handle)
if (releasedIt != mReleasedList.end())
{
mReleasedList.erase(releasedIt);
std::make_heap(mReleasedList.begin(), mReleasedList.end(), std::greater<GLuint>());
return;
}
}
......
......@@ -170,4 +170,27 @@ TEST(HandleAllocatorTest, ReserveAndAllocateIterated)
}
}
// This test reproduces invalid heap bug when reserve resources after release.
TEST(HandleAllocatorTest, ReserveAfterReleaseBug)
{
gl::HandleAllocator allocator;
for (int iteration = 1; iteration <= 16; ++iteration)
{
allocator.allocate();
}
allocator.release(15);
allocator.release(16);
for (int iteration = 1; iteration <= 14; ++iteration)
{
allocator.release(iteration);
}
allocator.reserve(1);
allocator.allocate();
}
} // anonymous namespace
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