Memory leak on compiling method call with kwargs
The following code produces a memory leak:
It comes from the allocation in
struct rb_callinfo_kwarg *kw_arg = rb_xmalloc_mul_add(len, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
Later it's packed into
struct rb_callinfo, but
imemo_callinfo is a GC-managed object that has no
free calls in
obj_free function in gc.c.
I've tried to fix it by calling
callinfo->kwarg and it fixed leak in
./miniruby -e 'p(foo: 1)', but it breaks
make install. My addition causes a double-free error, looks like either
callinfo->kwarg is shared between multiple objects.
kwarg field is a
const pointer, so that's somewhat expected (I was under impression that
const qualifier is redundant) :)
I'm pretty sure old versions of Ruby are also affected by this memory leak.