Skip to content

Fix data race between consumer of QueryParam.Entries and the sender #131

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrewphelpsj
Copy link

Hello! This patch is a small fix to a data race. If the calling code reads from the channel provided via QueryParam.Entries, there is a chance that they read from a pointer that is being mutated by the code in client.query. This happens because we mutate the data that the pointer points to, even after we send that pointer over the channel.

It looks like there was an attempt at fixing this a couple years ago: #75. The change proposed here differs a little bit, since I'm doing a deep copy of all of the data. This should prevent the calling code from messing with the internal state of the client.

It seems like this might not be the approach you all want, so if there is another potential solution, let me know and I'll be happy to try and submit a patch!

@andrewphelpsj andrewphelpsj requested review from a team as code owners April 29, 2025 17:42
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

1 similar comment
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

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.

1 participant