On Thu, Jan 9, 2014 at 2:13 PM, Mike Frysinger <
vap...@chromium.org> wrote:
> just leak memory instead ?
> while (1)
> malloc(1024 * 1024);
That fails to test what the test intends to test. It's specifically a test
to verify that libc's internal calls to an allocator use the interposed
malloc rather than libc's own malloc.
To add some more information without necessarily solving the problem:
What changed in libc is that *printf got more robust checking for integer
overflow in a variety of cases. In particular, it was decided that field
width and precision values are always 'int'. This was deemed to be
sensible given that when using %* or %.*, the dynamic field width or
precision is an 'int' argument. It now uniformly detects any such value
that tries to exceed INT_MAX, which is impossible with the dynamic
arguments but easy with static format strings like the one in this test.
Now *printf will fail with EOVERFLOW for this case before anything attempts
any kind of allocation.
So this could be addressed in a variety of ways:
1. Change the test setup so that the Chromium-supplied malloc is one that
fails characteristically with a size of INT_MAX or greater and then use
INT_MAX as the field width.
2. Use asprintf but verify that it's calling the right malloc in some way
other than by expecting it to fail because the size is too large. A
variety of options come to mind, but everything I've thought of just now
entails modifying the malloc function linked into the test program.
3. Use some other libc function that calls malloc and that can be reliably
(i.e. guaranteed by the documented API) to attempt a malloc call of a
very large size that you control.
I don't know off hand that there is such an interface to use or, if so,
what it is. Someone (like Mike or I) who is comfortable trolling
through the libc code could put some effort into finding one.
Thanks,
Roland