Re: [igt-dev] [PATCH i-g-t] tests: close(fd) without igt_fixture considered harmful

Petri Latvala
2018-11-26T12:55:30Z

On Mon, Nov 26, 2018 at 11:08:24AM +0100, Daniel Vetter 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).

Not sure if this is better... At least it's a doublecheck:

# for a in `find -maxdepth 1 -executable -type f`; do valgrind --log-file=${a}.valgrind $a --list-subtests; done

...

# grep 'close(fd)' *.valgrind
gem_tiled_fence_blits.valgrind:==32746== Syscall param close(fd) contains uninitialised byte(s)
gem_tiled_swapping.valgrind:==32441== Syscall param close(fd) contains uninitialised byte(s)

For a bonus missing igt_fixture,
gem_ctx_param.valgrind:==32483== Syscall param ioctl(fd) contains uninitialised byte(s)

--
Petri Latvala