Hi,

I am implementing a framework based on Memcached. There's a problem that 
confused me a lot. The framework basically change the eviction policy, so 
when it calls to evict an item, it might not evict the tail item at COLD 
LRU, instead it will look for a "more suitable" item to evict and it will 
reinsert the tail items to the head of COLD queue.

It mostly works fine, but sometimes it causes a SegFault when reinsertion 
happens very frequently (like in almost each eviction). The SegFault is 
triggered in the crawler part. As attached, it seems when the crawler loops 
through the item queue, it reaches an invalid memory address. The bug 
happens after around 50000000~10000000 GET/SET (9:1) operations. I used 
Memaslap for testing.

Could anyone give me some suggestions of the reasons which cause such error?

Here is the gdb messages:

*Thread 8 "memcached" received signal SIGSEGV, Segmentation fault.*

*[Switching to Thread 0x7ffff4d6c700 (LWP 36414)]*

*do_item_crawl_q (it=it@entry=0x55555579e7e0 <crawlers+12320>)*

*    at items.c:2015*

*2015             it->prev->next = it->next;*

*(gdb) print it->prev*

*$5 = (struct _stritem *) 0x4f4d6355616d5471*

*(gdb) print it->prev->next*

*Cannot access memory at address 0x4f4d6355616d5479*

*(gdb) print it->next*

*$6 = (struct _stritem *) 0x7a59324376753351*

*(gdb) print it->next->prev*

*Cannot access memory at address 0x7a59324376753361*

*(gdb) print it->nkey*

*$7 = 0 '\000'*

*(gdb) *
Here is the part that triggers the error:

*2012         assert(it->next != it);*

*2013         if (it->next) {*

*2014             assert(it->prev->next == it);*

*2015             it->prev->next = it->next;*

*2016             it->next->prev = it->prev;*

*2017         } else {*

*2018             /* Tail. Move this above? */*

*2019             it->prev->next = 0;*

*2020         }*

(I'm also confused why the assert function in line 2014 does not give 
error?)

Thank you very much for helping!

Best,

Qingchen

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/memcached/ed80d89c-eb8f-4682-9938-a7cd024d4d10n%40googlegroups.com.

Reply via email to