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
- Compile the project with the ARM port:
cmake .. -DPORT_DIR=ports/arm && make
- Run the KWS test:
./test_kws
- 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().
Summary
The
tests/test_kwsexecutable leaks memory allocated byth_nn_init()because it fails to callth_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 callsth_nn_init(), which allocates memory for the neural network context (e.g.,ctx.bufin the ARM CMSIS-NN port).The
test_kws.cmain function initializes the KWS instance but returns without callingth_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
cmake .. -DPORT_DIR=ports/arm && make./test_kwsth_initis called (allocating memory) butth_cleanupis 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().