Skip to content

Bug: Memory Leak in tests/test_kws #93

@Amit-Matth

Description

@Amit-Matth

Summary

The tests/test_kws executable leaks memory allocated by th_nn_init() because it fails to call th_cleanup()before exiting. This issue affects platforms where extensive memory allocation tracking is enabled or on bare-metal systems where cleanup is critical for repeated test execution without reset.

Description

The ee_kws_init() function calls th_nn_init(), which allocates memory for the neural network context (e.g., ctx.buf in the ARM CMSIS-NN port).
The test_kws.c main function initializes the KWS instance but returns without calling th_cleanup(), leaving the allocated memory unreleased.

Re-running the test in the same process or environment without improved cleanup leads to memory exhaustion or leakage warnings in improved testing environments.

Steps to Reproduce

  1. Compile the project with the ARM port: cmake .. -DPORT_DIR=ports/arm && make
  2. Run the KWS test: ./test_kws
  3. Observe that th_init is called (allocating memory) but th_cleanup is never called.

Expected Behavior

The test should release all allocated resources before exiting, ensuring a clean state for subsequent tests or executions.

Actual Behavior

The test exits without freeing the memory allocated by th_nn_init().

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions