es-ude / es-ude/OnDeviceTraining
freeReluLayer leaks the SYM qConfig scales array
- Dominant language
- C
- Stars
- 1
- Forks
- 3
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 8
Description
Found during the group-quant PR2 review (Task 5 fix-wave LSan run), pre-existing on develop — not introduced by the group-quant work.
**Bug:** `freeReluLayer` (src/userApi/layer/ReluApi.c:80,84) frees the owned quantization's `qConfig` directly without first freeing `qConfig->scales` for SYM-typed configs. Since the always-array migration (PR #402), every SYM qconfig owns a heap `scales` array (`reserveMemory` in `initSymQConfig`), so an owning Relu layer built with a SYM `outputQ` leaks that array on free.
**Correct pattern:** route the teardown through `freeQuantization` (TensorApi.c), which frees `scales` before the config — or replicate its SYM arm.
**Evidence:** LSan opt-in run (`detect_leaks=1`) of the new grouped-deserialize tests flagged it; the tests work around it via non-owning `reluLayerInit`. Other `free*Layer` implementations should be audited for the same pattern while fixing (grep for direct `freeReservedMemory(...->qConfig)` without a scales free).
Contributor guide
Research direction
Start in src/userApi/layer/ReluApi.c at freeReluLayer lines 80 and 84, then read freeQuantization in TensorApi.c to understand the teardown pattern. Use the LSan opt-in run and the grouped-deserialize tests as validation, and grep other free*Layer implementations for the same direct qConfig release. Done means the SYM scales allocation is released and the leak no longer appears.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100