parrot/parrot — Issue #729: Memory leak with hop_buckets in ops
Author: petdance
Created: 2012-03-05 20:09:22+00:00
State: open
Labels: Bug, Pri-minor

compilers/opsc/src/Ops/Trans/C.pm creates boilerplate code for a number of ops files:

src/dynoplibs/bit_ops.c
src/dynoplibs/debug_ops.c
src/dynoplibs/io_ops.c
src/dynoplibs/math_ops.c
src/dynoplibs/obscure_ops.c
src/dynoplibs/sys_ops.c
src/dynoplibs/trans_ops.c
src/ops/core_ops.c

In each of these, there's a `static HOP *hop_buckets` at the top of each file. Then, in `hop_init()` an automatic variable `hop_buckets` gets big chunks of memory allocated. Then in `hop_deinit()`, the static `hop_buckets` is freed, which does nothing because the static has never been set.

Thanks to GCC's -Wshadow argument for finding the local `hop_buckets` that shadows the static `hop_buckets`.