tess: avoid reading past the end of the gl_in array

Submitted by Ilia Mirkin on July 29, 2015, 3:45 p.m.

Details

Message ID 1438184714-9188-1-git-send-email-imirkin@alum.mit.edu
State New
Headers show

Not browsing as part of any series.

Commit Message

Ilia Mirkin July 29, 2015, 3:45 p.m.
Reading off the end causes out-of-bounds errors on nouveau, and one
might think that it's somehow barrier-related given the name of these
tests. If this is a valuable thing to test, there can be a separate test
for that.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---
 .../spec/arb_tessellation_shader/execution/barrier-patch.shader_test | 5 ++++-
 tests/spec/arb_tessellation_shader/execution/barrier.shader_test     | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test b/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
index d34fdc5..313e9d0 100644
--- a/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
+++ b/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
@@ -12,7 +12,10 @@  patch out int val[6];
 patch out vec4 pcolor;
 
 void main() {
-	gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+	if (gl_InvocationID < gl_PatchVerticesIn)
+		gl_out[gl_InvocationID].gl_Position =
+			gl_in[gl_InvocationID].gl_Position;
+
         if (gl_InvocationID < val.length())
                 val[gl_InvocationID] = gl_InvocationID;
 
diff --git a/tests/spec/arb_tessellation_shader/execution/barrier.shader_test b/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
index 8ac74f0..a505e79 100644
--- a/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
+++ b/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
@@ -12,7 +12,10 @@  out int val[];
 patch out vec4 pcolor;
 
 void main() {
-	gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+	if (gl_InvocationID < gl_PatchVerticesIn)
+		gl_out[gl_InvocationID].gl_Position =
+			gl_in[gl_InvocationID].gl_Position;
+
         if (gl_InvocationID < val.length())
                 val[gl_InvocationID] = gl_InvocationID;
 

Comments

It would be nice to keep these tests under names that say they test
out-of-bounds accesses.

Marek

On Wed, Jul 29, 2015 at 5:45 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> Reading off the end causes out-of-bounds errors on nouveau, and one
> might think that it's somehow barrier-related given the name of these
> tests. If this is a valuable thing to test, there can be a separate test
> for that.
>
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
>  .../spec/arb_tessellation_shader/execution/barrier-patch.shader_test | 5 ++++-
>  tests/spec/arb_tessellation_shader/execution/barrier.shader_test     | 5 ++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test b/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> index d34fdc5..313e9d0 100644
> --- a/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> +++ b/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> @@ -12,7 +12,10 @@ patch out int val[6];
>  patch out vec4 pcolor;
>
>  void main() {
> -       gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
> +       if (gl_InvocationID < gl_PatchVerticesIn)
> +               gl_out[gl_InvocationID].gl_Position =
> +                       gl_in[gl_InvocationID].gl_Position;
> +
>          if (gl_InvocationID < val.length())
>                  val[gl_InvocationID] = gl_InvocationID;
>
> diff --git a/tests/spec/arb_tessellation_shader/execution/barrier.shader_test b/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> index 8ac74f0..a505e79 100644
> --- a/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> +++ b/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> @@ -12,7 +12,10 @@ out int val[];
>  patch out vec4 pcolor;
>
>  void main() {
> -       gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
> +       if (gl_InvocationID < gl_PatchVerticesIn)
> +               gl_out[gl_InvocationID].gl_Position =
> +                       gl_in[gl_InvocationID].gl_Position;
> +
>          if (gl_InvocationID < val.length())
>                  val[gl_InvocationID] = gl_InvocationID;
>
> --
> 2.3.6
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
Yeah, you mentioned that on IRC... I agree, just haven't gotten around to
updating this patch. Probably won't for a week or so.

On Fri, Aug 7, 2015 at 7:22 AM, Marek Olšák <maraeo@gmail.com> wrote:

> It would be nice to keep these tests under names that say they test
> out-of-bounds accesses.
>
> Marek
>
> On Wed, Jul 29, 2015 at 5:45 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> > Reading off the end causes out-of-bounds errors on nouveau, and one
> > might think that it's somehow barrier-related given the name of these
> > tests. If this is a valuable thing to test, there can be a separate test
> > for that.
> >
> > Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> > ---
> >  .../spec/arb_tessellation_shader/execution/barrier-patch.shader_test |
> 5 ++++-
> >  tests/spec/arb_tessellation_shader/execution/barrier.shader_test     |
> 5 ++++-
> >  2 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git
> a/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> b/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> > index d34fdc5..313e9d0 100644
> > ---
> a/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> > +++
> b/tests/spec/arb_tessellation_shader/execution/barrier-patch.shader_test
> > @@ -12,7 +12,10 @@ patch out int val[6];
> >  patch out vec4 pcolor;
> >
> >  void main() {
> > -       gl_out[gl_InvocationID].gl_Position =
> gl_in[gl_InvocationID].gl_Position;
> > +       if (gl_InvocationID < gl_PatchVerticesIn)
> > +               gl_out[gl_InvocationID].gl_Position =
> > +                       gl_in[gl_InvocationID].gl_Position;
> > +
> >          if (gl_InvocationID < val.length())
> >                  val[gl_InvocationID] = gl_InvocationID;
> >
> > diff --git
> a/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> b/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> > index 8ac74f0..a505e79 100644
> > --- a/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> > +++ b/tests/spec/arb_tessellation_shader/execution/barrier.shader_test
> > @@ -12,7 +12,10 @@ out int val[];
> >  patch out vec4 pcolor;
> >
> >  void main() {
> > -       gl_out[gl_InvocationID].gl_Position =
> gl_in[gl_InvocationID].gl_Position;
> > +       if (gl_InvocationID < gl_PatchVerticesIn)
> > +               gl_out[gl_InvocationID].gl_Position =
> > +                       gl_in[gl_InvocationID].gl_Position;
> > +
> >          if (gl_InvocationID < val.length())
> >                  val[gl_InvocationID] = gl_InvocationID;
> >
> > --
> > 2.3.6
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
>