-
Notifications
You must be signed in to change notification settings - Fork 8
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
thread race condition accessing axl_kvtrees[id] #85
Comments
Good catch! We should add a wrapper function that gets the kvtree and handles the locking, like: - kvtree* file_list = axl_kvtrees[id];
+ kvtree* file_list = get_kvtree(id); |
If there is no objection I will try and give adding correct locking code, using a |
Branch https://github.com/rhaas80/AXL/tree/rhaas/locks contains an implementation protecting against the race condition. Changes are: rhaas80/AXL@rhaas/keyvalue...rhaas80:rhaas/locks Implementation notes:
|
@rhaas80 could you open a PR with those changes? |
Well it would be a pull request onto my own rhaas/keyvalue branch which itself still needs to be approved. So I can make it a work-in-progress. An actual pull does not make much sense. |
Here's a pull request, but as said it does not make that much sense to pull into my own branch. rhaas80#1 |
In
AXL/src/axl_pthread.c
Line 321 in a799cd9
axl_kvtrees
is accessed without protecting from race conditions.Looking eg at
AXL/src/axl.c
Line 98 in a799cd9
where one has
it seems clear that
axl_kvtress
is accessed in a multi-threaded context. Sincerealloc
can move the block of data when allocating memory ie innew_ptr = realloc(old_ptrs, new_size)
there is no guarantee thatnew_ptr == old-ptr
one must not assume thataxl_kvtrees[id]
is accessible without the lock.The text was updated successfully, but these errors were encountered: