Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 287 by [email protected]: assoc_delete issue.
http://code.google.com/p/memcached/issues/detail?id=287

Reported by [email protected], Sep 08, 2012

i find there may be a bug when delete a item from hash_table during i read the source code.

below is the source code, and during deleting a item, it will firstly find the before's value. but "**before" will pointer to a item to be deleted, and at last it make *before = nxt; and i think this will delete all items linked after this item, not this item, and cause all these items in *head and *tail (static item *heads[LARGEST_ID];static item *tails[LARGEST_ID];) can not be accessed forever,

maybe this can explain why some items can alive too long.


void assoc_delete(const char *key, const size_t nkey, const uint32_t hv) {
    item **before = _hashitem_before(key, nkey, hv);

    if (*before) {
        item *nxt;
        hash_items--;
        nxt = (*before)->h_next;
        (*before)->h_next = 0;   /* probably pointless, but whatever. */
        *before = nxt;
        return;
    }
    assert(*before != 0);
}

Attachments:
        IMAG0048.jpg  507 KB

Reply via email to