Skip to content

Conversation

@spinojara
Copy link

I agree with your previous conclusion that there are no race conditions during probing. However this patch is regarding the function probe_table and a possible init failure. Note that this race condition will never occur if all init's are successful (as was probably the case in your previous testing).

Consider the scenario where the same position is probed from two separate threads and init has not yet been done for the corresponding tb. If init_table fails it sets tbHash[hashIdx].ptr to NULL but the second thread checks the variable tbHash[hashIdx].ptr and then uses it if it is not NULL. This is a race condition.

We could either lock each time when checking the tbHash[hashIdx].ptr variable, but this is unnecessarily slow. My patch introduces a variable called error which handles this scenario.

@jdart1 jdart1 merged commit b54fe93 into jdart1:master Dec 8, 2024
@jdart1
Copy link
Owner

jdart1 commented Dec 8, 2024

Ok, thanks for the further explanation. Merging.

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

Successfully merging this pull request may close these issues.

2 participants