facebook / CacheLib

Pluggable in-process caching engine to build and scale high performance services
https://www.cachelib.org
Apache License 2.0
1.18k stars 254 forks source link

Segmentation fault while fetching refcount #315

Closed aaditya2200 closed 3 months ago

aaditya2200 commented 3 months ago

In the following code: template Referent cache_get(uint64_t node_target) { object obj; auto handle = get(std::to_string(node_target), obj); if (!handle) { obj = load(node_target, 0); } lock.get_read_lock(node_target); return (Referent )obj.target; }

get is defined as follows: CacheReadHandle cache::get(CacheKey key, object &obj) const { auto handle = gcache_->find(key); if (handle) { std::memcpy(static_cast<void *>(&obj), handle->getMemory(), sizeof(obj)); } }

after the return statement in cacheget, the code tries to fetch the refCount variable in Refcount.h in the function atomicUpdateValue. The segmentation fault is on line 471.

aaditya2200 commented 3 months ago

Basically, as soon as handle goes out of scope, a seg fault happens. Is there a way to release the handle somehow?

aaditya2200 commented 3 months ago

I somehow managed to fix this