Skip to content

Leak when shrinking hash table  #2271

Description

@zuiderkwast

Follow-up of #2257

After some more testing, I found that in its current form the test causes another ASAN error. I ran it in a loop with the fix applied and it sometimes causes a different memory leak. Not sure what causes this--maybe some edge case when doing a lot of short expiries:

[err]: Sanitizer error: 
=================================================================
==38307==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f864c1da753 in __interceptor_calloc (/lib64/libasan.so.4+0xd8753)
    #1 0x4ae4f2 in ztrycalloc_usable_internal /home/gusakovy/Projects/valkey/src/zmalloc.c:214
    #2 0x4ae7bd in valkey_calloc /home/gusakovy/Projects/valkey/src/zmalloc.c:257
    #3 0x4726b9 in bucketConvertToChained /home/gusakovy/Projects/valkey/src/hashtable.c:776
    #4 0x4733cf in findBucketForInsert /home/gusakovy/Projects/valkey/src/hashtable.c:889
    #5 0x470f02 in rehashBucket /home/gusakovy/Projects/valkey/src/hashtable.c:536
    #6 0x47125b in rehashStep /home/gusakovy/Projects/valkey/src/hashtable.c:551
    #7 0x475713 in hashtableRehashMicroseconds /home/gusakovy/Projects/valkey/src/hashtable.c:1225
    #8 0x47f4fd in kvstoreIncrementallyRehash /home/gusakovy/Projects/valkey/src/kvstore.c:658
    #9 0x485c75 in databasesCron /home/gusakovy/Projects/valkey/src/server.c:1308
    #10 0x486ef8 in serverCron /home/gusakovy/Projects/valkey/src/server.c:1577
    #11 0x4637dd in processTimeEvents /home/gusakovy/Projects/valkey/src/ae.c:370
    #12 0x4643e3 in aeProcessEvents /home/gusakovy/Projects/valkey/src/ae.c:513
    #13 0x4647ea in aeMain /home/gusakovy/Projects/valkey/src/ae.c:543
    #14 0x4a6262 in main /home/gusakovy/Projects/valkey/src/server.c:7291
    #15 0x7f864b40c139 in __libc_start_main (/lib64/libc.so.6+0x21139)

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).

I think its best to just merge the fix and maybe open a separate issue for this.

Originally posted by @gusakovy in #2257 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions