[1.3] bucket.Put: copy key before seek#639
Merged
ahrtr merged 5 commits intoetcd-io:release-1.3from Dec 18, 2023
Merged
Conversation
fuweid
commented
Dec 13, 2023
As per `go build -gcflags -m ./... 2>&1`: Old behaviour: ``` ./bucket.go:148:31: leaking param: key ./bucket.go:192:42: leaking param: key ./bucket.go:271:22: leaking param: key ``` Now: ``` ./bucket.go:148:31: key does not escape ./bucket.go:192:42: key does not escape ./bucket.go:271:22: key does not escape ``` Signed-off-by: Evgenii Stratonikov <fyfyrchik@runbox.com> (cherry picked from commit 71a59ca) Signed-off-by: Wei Fu <fuweid89@gmail.com>
581c892 to
31b5a34
Compare
ahrtr
reviewed
Dec 14, 2023
| c.node().put(key, key, value, 0, bucketLeafFlag) | ||
| // Tip: Use a new variable `newKey` instead of reusing the existing `key` to prevent | ||
| // it from being marked as leaking, and accordingly cannot be allocated on stack. | ||
| newKey := cloneBytes(key) |
Member
There was a problem hiding this comment.
I think we should clone the key before seek (line 167). Please update the main branch firstly. Thanks.
Signed-off-by: Wei Fu <fuweid89@gmail.com> (cherry picked from commit 324df9c) Signed-off-by: Wei Fu <fuweid89@gmail.com>
Signed-off-by: Wei Fu <fuweid89@gmail.com> (cherry picked from commit 1b08078) Signed-off-by: Wei Fu <fuweid89@gmail.com>
Application might change key value after seeking and before real put. This unexpected behaviour could corrupt database. When users file issue, maintainers doesn't know application behaviour. It could be caused by data race. This patch is to prevent such case and save maintainers' time. Signed-off-by: Wei Fu <fuweid89@gmail.com> (cherry picked from commit a05ec68) Signed-off-by: Wei Fu <fuweid89@gmail.com>
It's follow-up of etcd-io#637. Signed-off-by: Wei Fu <fuweid89@gmail.com> (cherry picked from commit 62d8026) Signed-off-by: Wei Fu <fuweid89@gmail.com>
31b5a34 to
fabe2fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cherry-pick: