[vlc-devel] [PATCH] Temporarily work around crashing on Windows due to %zu

Rémi Denis-Courmont rem at videolan.org
Mon Nov 17 21:23:25 CET 2008


On Monday 17 November 2008 18:59:21 David Flynn, you wrote:
> On 2008-11-17, Rémi Denis-Courmont <rem at videolan.org> wrote:
> > On Monday 17 November 2008 13:08:28 Pierre Ynard, you wrote:
> >> The printf functions on Windows don't support the z length modifier,
> >> which can shift field arguments, and causes an unconditional crash in
> >> modules.c on start-up. For now, strip it on Windows and have vlc work
> >> again, until a better solution is found and applied.
> >
> > In this particular case, storing an unsigned instead of a size_t would be
> > simpler. But my concern remain that this fix is pointless as it only
> > addresses the tip of the iceberg. We have quite a bunch of other %z and
> > %j throughout and not all of them can/should be turned into ints.
>
> I had a quick grep for the %zu, and this was the only place where it
> caused a severe issue (came before %s).
>
> Just to write it up, there have been two suggestions sofar:
>
> 1) invent PRzu or whatever
>    Some have complained that this causes gettext issues, however, there
>    are no instances [that i could quickly find] that %zu is used with
>    _N("...");
>
>    So, is the gettext objection a non-issue? (see also PRId64)

AFAIK, gettext _does_ support the standard C PRI... macros internally. It will 
not support VLC-specific extensions.

> 2) accept the fact that windows sucks and modify the wrappers that call
>    vsnprintf, to first fmt' = strdup(fmt), then scan fmt for offending
>    formats and convert them to the correct one on win32 (then
>    free(fmt')).

Well, you don't even need strdup, if this a concern.
And it cannot be that difficult to replace all occurences of %z with %l (which 
does work on Win32, not sure about Win64) and redirect *printf() using 
macros - we already do it for opendir().

> 3) steal the *printf fro gnu libc

Bulldozer to crush a mosquitoe.

-- 
Rémi Denis-Courmont



More information about the vlc-devel mailing list