[strace/strace] static assert (#133)

Dmitry V. Levin ldv at altlinux.org
Tue May 26 11:25:57 UTC 2020


On Thu, Apr 16, 2020 at 02:51:28PM -0700, strace-devel mailing list wrote:
> On Fri, Apr 10, 2020 at 01:20:03PM -0700, Jory A. Pratt wrote:
> > In file included from static_assert.h:11,
> >                  from v4l2.c:13:
> > xlat/v4l2_ioctl_cmds.h:43:1: error: static assertion failed: "VIDIOC_QUERYBUF != _IOWR(\'V\',   9, struct_v4l2_buffer)"
> >    43 | static_assert((VIDIOC_QUERYBUF) == (_IOWR('V',   9, struct_v4l2_buffer)), "VIDIOC_QUERYBUF != _IOWR('V',   9, struct_v4l2_buffer)");
> >       | ^~~~~~~~~~~~~
> > xlat/v4l2_ioctl_cmds.h:64:1: error: static assertion failed: "VIDIOC_QBUF != _IOWR(\'V\',  15, struct_v4l2_buffer)"
> >    64 | static_assert((VIDIOC_QBUF) == (_IOWR('V',  15, struct_v4l2_buffer)), "VIDIOC_QBUF != _IOWR('V',  15, struct_v4l2_buffer)");
> >       | ^~~~~~~~~~~~~
> > xlat/v4l2_ioctl_cmds.h:71:1: error: static assertion failed: "VIDIOC_DQBUF != _IOWR(\'V\',  17, struct_v4l2_buffer)"
> >    71 | static_assert((VIDIOC_DQBUF) == (_IOWR('V',  17, struct_v4l2_buffer)), "VIDIOC_DQBUF != _IOWR('V',  17, struct_v4l2_buffer)");
> > 
> > This is build using linux-headers-5.6 with musl-1.2.0, this is a regression as 5.5 compiles fine.
> 
> The reason why 5.5 compiles fine is that the check was introduced in 5.6,
> but the problem lies elsewhere.
> 
> Definitions of VIDIOC_QUERYBUF, VIDIOC_QBUF, and VIDIOC_DQBUF in
> <linux/videodev2.h> use struct v4l2_buffer which in turn uses struct timeval.
> 
> The size of struct timeval on a traditional 32-bit architecture
> like x86 depends on libc and its version thanks to time_t problem.
> 
> As result, the value of VIDIOC_QUERYBUF on a traditional 32-bit
> architecture like x86 depends on libc and its version.
> 
> When v4l2.c is compiled in mpers mode to handle x86 and x32 personality
> syscalls on x86_64, the value for VIDIOC_QUERYBUF is taken from the
> appropriate linux/*/ioctls_inc*.h file.  There is only one value there for
> each architecture, not two.  If you are unhappy enough to have time_t size
> different from the one used to generate that ioctls_inc file, you get this
> failed assertion.
> 
> The kernel starting with Linux kernel commit v5.6-rc1~93^2~102
> supports both sets of ioctl values, but strace will recognize
> and decode only one of them so far.
> 
> I don't see an easy fix of this issue for early adopters of 64-bit
> time_t on 32-bit architectures, sorry.

I suggest to force VIDIOC_DQBUF, VIDIOC_DQEVENT, VIDIOC_PREPARE_BUF,
VIDIOC_QBUF, and VIDIOC_QUERYBUF constants to be defined using
struct __kernel_v4l2_timeval instead of struct timeval.  This also means
we wouldn't be able to use struct v4l2_buffer neither in the decoder nor
in tests.


-- 
ldv


More information about the Strace-devel mailing list