code queries

Bran S archsbran at
Wed Jul 15 17:27:03 UTC 2020

On Sun, 12 Jul 2020 at 17:42, Dmitry V. Levin <ldv at> wrote:
> On Fri, Jul 10, 2020 at 05:32:44PM +0530, Bran S wrote:
> > I have seen tail_alloc() being used at a lot of places in tests. For
> > example, in ioctl_hdio.c, and epoll_pwait.c.
> >
> > File tests.h gives information about what it does but I don't
> > understand the motive and use of allocating memory in such a manner.
> > What is the purpose of it? How is it helpful in testing?
> This way we check whether strace decoders handle incomplete read from
> tracee's memory properly, and also check that strace decoders do not read
> beyond the end of structures being decoded.

Thanks, understood.
Could you please elaborate on this magic calculation that is going on here.

        const size_t len = (size + page_size - 1) & -page_size;

I have tried running it in several variations, but I fail to see the
pattern by which value of the variable `len` changes.
Why is doing this required?

More information about the Strace-devel mailing list