public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	IGT development <igt-dev@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t] tests: close(fd) without igt_fixture considered harmful
Date: Mon, 26 Nov 2018 14:10:08 +0200	[thread overview]
Message-ID: <8736roca5b.fsf@intel.com> (raw)
In-Reply-To: <20181126100824.31623-1-daniel.vetter@ffwll.ch>

On Mon, 26 Nov 2018, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> Some tests assume that close on an unopened fd is fine, except it's
> not just unopened but actually stack garbage. There's a good chance we
> end up running close(0), which wreaks the testcase enumeration. Fix
> this.
>
> Not sure there's a better way to catch this than git grep plus lots of
> manual auditing ... The unit tests only catch it by accident (x86
> works fine, I hit it in one testcase only cross-building to aarch64).
>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  tests/i915/gem_pread_after_blit.c  | 3 ++-
>  tests/i915/gem_tiled_fence_blits.c | 3 ++-
>  tests/i915/gem_tiled_swapping.c    | 3 ++-
>  3 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tests/i915/gem_pread_after_blit.c b/tests/i915/gem_pread_after_blit.c
> index 6ef3ca200776..cee9212749d6 100644
> --- a/tests/i915/gem_pread_after_blit.c
> +++ b/tests/i915/gem_pread_after_blit.c
> @@ -248,5 +248,6 @@ igt_main
>  		drm_intel_bufmgr_destroy(bufmgr);
>  	}
>  
> -	close(fd);

This one isn't stack garbage, it's guaranteed to be 0 for
!igt_fixture. The other two are garbage on stack.

The change is

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

but please update the commit message.

> +	igt_fixture
> +		close(fd);
>  }
> diff --git a/tests/i915/gem_tiled_fence_blits.c b/tests/i915/gem_tiled_fence_blits.c
> index c02e35a5fe4c..2453bcc0b271 100644
> --- a/tests/i915/gem_tiled_fence_blits.c
> +++ b/tests/i915/gem_tiled_fence_blits.c
> @@ -230,5 +230,6 @@ igt_main
>  		run_test(fd, count);
>  	}
>  
> -	close(fd);
> +	igt_fixture
> +		close(fd);
>  }
> diff --git a/tests/i915/gem_tiled_swapping.c b/tests/i915/gem_tiled_swapping.c
> index dce668063014..ddf2a748fc84 100644
> --- a/tests/i915/gem_tiled_swapping.c
> +++ b/tests/i915/gem_tiled_swapping.c
> @@ -235,5 +235,6 @@ igt_main
>  			thread_fini(&threads[n]);
>  	}
>  
> -	close(fd);
> +	igt_fixture
> +		close(fd);
>  }

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2018-11-26 12:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 10:08 [igt-dev] [PATCH i-g-t] tests: close(fd) without igt_fixture considered harmful Daniel Vetter
2018-11-26 12:10 ` Jani Nikula [this message]
2018-11-26 14:26   ` Daniel Vetter
2018-11-26 12:55 ` Petri Latvala
2018-11-26 13:41 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-11-26 17:30 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8736roca5b.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox