Skip to content

[BUG] Memory address is accessed after it's free'd #61

@xiaocj

Description

@xiaocj

Describe the bug

Run the tairhash test cases with valgrind. The error is very likely to be triggered.

To reproduce

"./runtest --valgrind --single unit/tairhash"

Expected behavior

==50975== Invalid read of size 8
==50975== at 0x6FF7B18: passiveExpire (scan_algorithm.c:253)
==50975== by 0x6FFAC53: TairHashTypeHset_RedisCommand (tairhash.c:734)
==50975== by 0x6FFAC53: TairHashTypeHset_RedisCommand (tairhash.c:722)
==50975== by 0x274855: ValkeyModuleCommandDispatcher (module.c:1006)
==50975== by 0x19CD13: call (server.c:3739)
==50975== by 0x19E9CF: processCommand (server.c:4362)
==50975== by 0x1BFB34: processCommandAndResetClient (networking.c:3047)
==50975== by 0x1BFE4C: processInputBuffer (networking.c:3175)
==50975== by 0x1C02C0: readQueryFromClient (networking.c:3280)
==50975== by 0x2B8F09: callHandler (connhelpers.h:79)
==50975== by 0x2B9724: connSocketEventHandler (socket.c:300)
==50975== by 0x1857C6: aeProcessEvents (ae.c:486)
==50975== by 0x185A04: aeMain (ae.c:543)
==50975== Address 0x88b9838 is 24 bytes inside a block of size 40 free'd
==50975== at 0x484988F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==50975== by 0x1AC449: zfree_internal (zmalloc.c:399)
==50975== by 0x1AC486: valkey_free (zmalloc.c:414)
==50975== by 0x27375C: VM_Free (module.c:590)
==50975== by 0x7005A93: m_zslFreeNode (skiplist.c:43)
==50975== by 0x7005A93: m_zslDelete (skiplist.c:176)
==50975== by 0x6FF7DC9: deleteAndPropagate (scan_algorithm.c:294)
==50975== by 0x6FFAB91: fieldExpireIfNeeded (tairhash.c:298)
==50975== by 0x6FF7B4D: passiveExpire (scan_algorithm.c:243)
==50975== by 0x6FFAC53: TairHashTypeHset_RedisCommand (tairhash.c:734)
==50975== by 0x6FFAC53: TairHashTypeHset_RedisCommand (tairhash.c:722)
==50975== by 0x274855: ValkeyModuleCommandDispatcher (module.c:1006)
==50975== by 0x19CD13: call (server.c:3739)
==50975== by 0x19E9CF: processCommand (server.c:4362)
==50975== Block was alloc'd at
==50975== at 0x4846828: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==50975== by 0x1ABC91: ztrymalloc_usable_internal (zmalloc.c:155)
==50975== by 0x1ABE07: zmalloc_usable (zmalloc.c:199)
==50975== by 0x273667: VM_Alloc (module.c:552)
==50975== by 0x7005741: m_zslCreateNode (skiplist.c:12)
==50975== by 0x7005741: m_zslInsert (skiplist.c:104)
==50975== by 0x6FFB4DD: TairHashTypeHset_RedisCommand (tairhash.c:882)
==50975== by 0x6FFB4DD: TairHashTypeHset_RedisCommand (tairhash.c:722)
==50975== by 0x274855: ValkeyModuleCommandDispatcher (module.c:1006)
==50975== by 0x19CD13: call (server.c:3739)
==50975== by 0x19E9CF: processCommand (server.c:4362)
==50975== by 0x1BFB34: processCommandAndResetClient (networking.c:3047)
==50975== by 0x1BFE4C: processInputBuffer (networking.c:3175)
==50975== by 0x1C02C0: readQueryFromClient (networking.c:3280)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions