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

Fix RSis.CopyWithFreshBuffer #402

Merged

Conversation

AlexandreBelling
Copy link
Collaborator

Fix CopyWithFreshBuffer

CopyWithFreshBuffer is a method of RSis whose intended role is to enable hashing in parallel by creating short-lived "clones" of the key. The present PR fixes a bug related to this.

Description of the bug

Prior to this PR, CopyWithFreshBuffer would shallow copy the private fields bufM, bufRes and bufMValues. As a result, attempting to use several copies of the same key concurrently results in a race condition (the same buffer being used by all the threads at the same time).

The fix

The proposed fix is to also initialize the rest of the buffers

	res.bufM = make(fr.Vector, len(r.bufM))
	res.bufMValues = bitset.New(r.bufMValues.Len())
	res.bufRes = make(fr.Vector, len(r.bufRes))

@gbotrel gbotrel merged commit d084e89 into Consensys:develop May 8, 2023
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.

None yet

2 participants