This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Memory corruption in nrf_log_frontend.c (NRF_LOG_FILTERS_ENABLED in nRF5_SDK 15.2.0)

I am in the progress of updating to nRF5_SDK 15.2.0 from 15.0.0, project on nRF52840/Segger Embedded Studio.

I have NRF_LOG_FILTERS_ENABLED defined since I want to log less over UART than to my crash logger.

It seems that the code on line 174 in nrf_log_init() in nrf_log_frontend.c writes to another modules memory. I traced the reason to be that __log_dynamic_data_run_size__ == 0, and thus the pointer assigned on line 172 being pointing into the next section.

Is this correct, or have I misconfigured something?

My workaround for now is to turn off log filtering.

The offending code from nrf_log_frontends.c (line 1 in the snippet is line 169 in nrf_log_frontents.c)

        for (i = 0; i < modules_cnt; i++)
        {
            nrf_log_module_dynamic_data_t * p_module_ddata = NRF_LOG_DYNAMIC_SECTION_VARS_GET(i);
            nrf_log_module_filter_data_t * p_module_filter = NRF_LOG_FILTER_SECTION_VARS_GET(i);
            p_module_ddata->filter = 0;
            p_module_filter->filter_lvls = 0;
        }

Related