Skip to content

Fix all direct MAC memory leaks

This MR fixes many memory leaks in the MAC that are otherwise shown by asan if the gNB is started. UEs can be connected and it seems the MAC does not leak memory. It also fixes a number of memory problems where e.g., the generation of SIB1 "steals" memory from the ServingCellConfigCommon. See the commits for more details.

Note that this still leaves behind a lot of memory after calling the new function mac_top_destroy_gNB(). To see them, add free(mac); in that function. However, there are no "direct leaks", so it would be feasible to still clean up (it's just that we don't do it, yet).

I checked. In a "standard" configuration (FR1, 30kHz), the memory leaks come basically from RRC. Also, the F1 UE context setup message leaks some memory, which we will handle in the future by adding encoding/decoding functions that with corresponding utility (free, copy) functions. On the other hand, the frequent F1 messages (UL/DL RRC Message Transfer) do not leak memory (they have the utility functions).

A final commit just makes the inability to write nrRRC_stats.log, nrL1_stats.log, and nrMAC_stats.log, non-fatal to the gNB.

Edited by Robert Schmidt

Merge request reports

Loading