[PATCH 6/7] Avoid using a union for ctl_node_s

Jason Evans jasone at canonware.com
Mon Apr 23 11:33:39 PDT 2012


On Apr 22, 2012, at 11:50 PM, Mike Hommey wrote:
> On Sun, Apr 22, 2012 at 01:09:07AM -0700, Jason Evans wrote:
>> On Apr 19, 2012, at 11:38 PM, Mike Hommey wrote:
>>> From: Mike Hommey <mh at glandium.org>
>>> 
>>> MSVC doesn't support C99, and as such doesn't support designated
>>> initialization of structs and unions. As there is never a mix of
>>> indexed and named nodes, it is pretty straightforward to use a
>>> different type for each.
>>> ---
>>> include/jemalloc/internal/ctl.h |   27 ++++---
>>> src/ctl.c                       |  164 +++++++++++++++++++++++----------------
>>> 2 files changed, 110 insertions(+), 81 deletions(-)
>> 
>> This patch causes crashes if MALLOC_CONF=stats_print:true is set.
> 
> I ran all the tests with MALLOC_CONF=stats_print:true and got no crash.
> Do you have a testcase?
> 
> Mike

This crashes on both Linux and FreeBSD:

	MALLOC_CONF=stats_print:true LD_PRELOAD=/home/je/jemalloc/lib/libjemalloc.so.1 /bin/ls

Anyway, I just found the problem: ctl_indexed_node() has its conditional reversed, so it returns NULL for indexed nodes.  I'll commit with the fix integrated, assuming no other problems show up.

Jason


More information about the jemalloc-discuss mailing list