Patch: Use calloc instead of malloc when running out of VSM space (common_vsm.c)
Poul-Henning Kamp
phk at phk.freebsd.dk
Wed Mar 9 09:09:51 CET 2016
--------
In message <CAMNFQgP-jCt2DYKTmfp49255m6JybZ8hpOZ6DRZe5hPUkwrU3g at mail.gmail.com>
, =?UTF-8?Q?P=C3=A5l_Hermunn_Johansen?= writes:
>Subject: [PATCH] Use calloc instead of malloc to allocate extra VSM space.
>
>With malloc we would read from uninitialized memory (implicitly with ++ or +=).
>
>Also expanded comment: When we need to allocate extra VSM space
>with malloc/calloc, the space will not be available to other
>processes. The workaround is to increase VSM space through the
>runtime parameter vsm_space.
Good catch.
The comment isn't going to help anybody very much though, it would be
a better idea to improve on the comments on the vsm_overflow[ed]
counters where people can see them.
Personally the "did/does" difference was too subtle for me to spot,
and I spent some time trying to find out why we had two counters
with the exact same definition.
It does not look like we emit a SLT_Error record when this happens,
I think we should. VSM_Alloc() looks like the best place for it,
but there is a chicken and egg issue since VSM_Alloc is also used
to allocate the VSL buffer.
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the varnish-dev
mailing list