Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tlsf memory manager status weirdness #2628

Closed
lazedo opened this issue Feb 7, 2021 · 2 comments
Closed

tlsf memory manager status weirdness #2628

lazedo opened this issue Feb 7, 2021 · 2 comments

Comments

@lazedo
Copy link
Contributor

lazedo commented Feb 7, 2021

Description

TLSF mem manager accounting for wrong values

was trying to debug a crash and this popped up.

using a lot of small allocs until pkg_alloc returns NULL (when exhausted)
when NULL is returned the memory used+overhead exceeds the heap allocated.

Troubleshooting

Reproduction

use frequent small memory allocs until pool is exausted (returns NULL) , check tlsf status.

static void do_test_mem()
{
    void* chunk;
    tlsf_t pool = NULL;
    size_t total = 16 * 1024 * 1024;
    size_t half = 8 * 1024 * 1024;
    size_t sz = 6;
    int x;
    void* mem = malloc(total);
    char* mem2 = tlsf_cast(char*, tlsf_cast(ptrdiff_t, mem) + half);
    memset(mem2, 'X', half);
    assert(*mem2 == 'X');
    pool = tlsf_create_with_pool(mem, half);
    do { chunk = tlsf_malloc(pool, sz); } while(chunk != NULL);
    tlsf_status(pool);
    for(x=0; x < half; x++) {
        assert(*mem2 == 'X');
        mem2++;
    }
    free(mem);
}
heap size= **8388592**
used= **6285144**, used+overhead=**12578696**, free=**18446744073705361512**, fragments=0
max used (+overhead)=12578696, max fragments=1
Free blocks matrix ('.': none, 'X': between 2^X and (2^(X+1)-1) free blocks, X=A..Z, A=0, B=1, ...)
> first-level: 32 block list arrays between 2^fl and 2^(fl+1) bytes (fl=8..39)
v second-level: 32 block lists between 2^fl+sl*2^(fl-5) and 2^fl+(sl+1)*2^(fl-5)-1 bytes (sl=0..31)
 0|................................|
 1|................................|
 2|................................|
 3|................................|
 4|................................|
 5|................................|
 6|................................|
 7|................................|
 8|................................|
 9|................................|
10|................................|
11|................................|
12|................................|
13|................................|
14|................................|
15|................................|
16|................................|
17|................................|
18|................................|
19|................................|
20|................................|
21|................................|
22|................................|
23|................................|
24|................................|
25|................................|
26|................................|
27|................................|
28|................................|
29|................................|
30|................................|
31|................................|

Log Messages

identical to reproduce step when calling mem debug on a running instance

Possible Solutions

Additional Information

  * **Kamailio Version** - built from master
  • Operating System:
CentOS7 and alpine

comments

heap size= 8388592 shouldn't it be 8388608 ?
used+overhead=12578696 misleading
free=18446744073705361512 misleading, looks like it has a negative value
the map doesn't look ok (or i'm not understanding what it should show), its the same output before the alloc and after.

@miconda
Copy link
Member

miconda commented Feb 8, 2021

The original developer of the code is no longer active, I can try to look over it as I get some time during next days, if nobody else does it meanwhile.

@lazedo - as we help with this one, can you take care of #976 ? It is an old one related to the kazoo module that you maintain -- check if it is still something to fix the docs or if already done, close it.

Copy link

github-actions bot commented Nov 8, 2023

This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.

@github-actions github-actions bot added the Stale label Nov 8, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants