Under what condition would tlsf_assert(block_size(block) >= size) occur

Description

I’m using LVGL 8.1, and meet below assertion.
tlsf_assert(block_size(block) >= size);
I wonder under what condition that this assertion would happen, and how should I fix/avoid such problem.

What MCU/Processor/Board and compiler are you using?

What LVGL version are you using?

v8.1

What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

static block_header_t * block_locate_free(control_t * control, size_t size)
{
    int fl = 0, sl = 0;
    block_header_t * block = 0;

    if(size) {
        mapping_search(size, &fl, &sl);

        /*
        ** mapping_search can futz with the size, so for excessively large sizes it can sometimes wind up
        ** with indices that are off the end of the block array.
        ** So, we protect against that here, since this is the only callsite of mapping_search.
        ** Note that we don't need to check sl, since it comes from a modulo operation that guarantees it's always in range.
        */
        if(fl < FL_INDEX_COUNT) {
            block = search_suitable_block(control, &fl, &sl);
        }
    }

    if(block) {
        tlsf_assert(block_size(block) >= size);
        remove_free_block(control, block, fl, sl);
    }

    return block;
}

Any suggestion is appreciated.
Many Thanks.

Hi,

I am facing similar issue with RT1176 controller configured with 8MB SD RAM.
Can you please let us know on possible reasons/solutions for crash/hang in
tlsf_assert(block_size(block) >= size);

Thanks,
Vijay

The tlsf error indicates that memory corruption has occurred, such as: memory at an illegal address is released; an array is written out of bounds; memory is used after being freed.
It is recommended to put the UI program on the simulator for debugging, configure the memory allocation interface in lv_conf.h as the C standard interface, and enable the AddressSanitizer · google/sanitizers Wiki · GitHub tool for debugging, which can be effective Capture memory access errors.

1 Like