[Piglit] [PATCH 4/4] fbo: Trigger a Mesa segfault with an FBO with invalid texture attached
Ian Romanick
idr at freedesktop.org
Sat Jul 27 16:10:39 PDT 2013
From: Ian Romanick <ian.d.romanick at intel.com>
Attach a really broken texture to an FBO, unbind the FBO, rebind the
FBO: boom!
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
tests/all.tests | 1 +
tests/fbo/CMakeLists.gl.txt | 1 +
tests/fbo/fbo-incomplete-invalid-texture.c | 112 +++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 tests/fbo/fbo-incomplete-invalid-texture.c
diff --git a/tests/all.tests b/tests/all.tests
index 32259ec..fbf6a10 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1098,6 +1098,7 @@ add_plain_test(arb_framebuffer_object, 'fbo-luminance-alpha')
add_plain_test(arb_framebuffer_object, 'fbo-getframebufferattachmentparameter-01')
add_plain_test(arb_framebuffer_object, 'fbo-gl_pointcoord')
add_plain_test(arb_framebuffer_object, 'fbo-incomplete')
+add_concurrent_test(arb_framebuffer_object, 'fbo-incomplete-invalid-texture')
add_plain_test(arb_framebuffer_object, 'fbo-incomplete-texture-01')
add_plain_test(arb_framebuffer_object, 'fbo-incomplete-texture-02')
add_plain_test(arb_framebuffer_object, 'fbo-incomplete-texture-03')
diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt
index b0604b2..706e63f 100644
--- a/tests/fbo/CMakeLists.gl.txt
+++ b/tests/fbo/CMakeLists.gl.txt
@@ -65,6 +65,7 @@ piglit_add_executable (fbo-generatemipmap-viewport fbo-generatemipmap-viewport.c
piglit_add_executable (fbo-getframebufferattachmentparameter-01 fbo-getframebufferattachmentparameter-01.c)
piglit_add_executable (fbo-gl_pointcoord fbo-gl_pointcoord.c)
piglit_add_executable (fbo-incomplete fbo-incomplete.cpp)
+piglit_add_executable (fbo-incomplete-invalid-texture fbo-incomplete-invalid-texture.c)
piglit_add_executable (fbo-incomplete-texture-01 fbo-incomplete-texture-01.c)
piglit_add_executable (fbo-incomplete-texture-02 fbo-incomplete-texture-02.c)
piglit_add_executable (fbo-incomplete-texture-03 fbo-incomplete-texture-03.c)
diff --git a/tests/fbo/fbo-incomplete-invalid-texture.c b/tests/fbo/fbo-incomplete-invalid-texture.c
new file mode 100644
index 0000000..0d11a3e
--- /dev/null
+++ b/tests/fbo/fbo-incomplete-invalid-texture.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * \file fbo-incomplete.c
+ * Collection of negative framebuffer completeness tests.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const float green[] = { 0.f, 1.f, 0.f, 1.f };
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+ GLuint tex;
+ GLuint fbo;
+ GLenum status;
+
+ piglit_require_extension("GL_ARB_framebuffer_object");
+
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+
+ /* The format of the pixel data is invalide for the specified
+ * internalFormat. This should fail and generate
+ * GL_INVALID_OPERATION. This leaves the texture in a weird, broken
+ * state.
+ */
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 4, 4, 0,
+ GL_RGBA, GL_FLOAT, NULL);
+ if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
+ pass = false;
+ goto cleanup;
+ }
+
+ /* Attach the broken texture to the FBO.
+ */
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, tex, 0);
+ if (!piglit_check_gl_error(GL_NO_ERROR)) {
+ pass = false;
+ goto cleanup;
+ }
+
+ /* Unbind and rebind the FBO. At one point on Mesa this triggered a
+ * segfault down inside the glBindFramebuffer code.
+ */
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+
+ status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) {
+ fprintf(stderr,
+ "status was %s (0x%04x), expected %s (0x%04x).\n",
+ piglit_get_gl_enum_name(status),
+ status,
+ "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT",
+ GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
+ pass = false;
+ goto cleanup;
+ }
+
+cleanup:
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+
+ glDeleteTextures(1, &tex);
+ glDeleteFramebuffers(1, &fbo);
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
--
1.8.1.4
More information about the Piglit
mailing list