Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault while fetching refcount #315

Closed
aaditya2200 opened this issue May 25, 2024 · 2 comments
Closed

Segmentation fault while fetching refcount #315

aaditya2200 opened this issue May 25, 2024 · 2 comments

Comments

@aaditya2200
Copy link

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 cache_get, the code tries to fetch the refCount_ variable in Refcount.h in the function atomicUpdateValue. The segmentation fault is on line 471.

@aaditya2200
Copy link
Author

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

@aaditya2200
Copy link
Author

I somehow managed to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant