Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Issue 1911263002: Fix memory corruption bug in impl/memory (Closed)

Created:
4 years, 8 months ago by iannucci
Modified:
4 years, 8 months ago
Reviewers:
dnj
CC:
chromium-reviews, infra-reviews+luci-gae_chromium.org
Base URL:
https://chromium.googlesource.com/external/github.com/luci/gae@master
Target Ref:
refs/heads/master
Project:
luci-gae
Visibility:
Public.

Description

Fix memory corruption bug in impl/memory When you `SetCollection` in gkvlite, it invalidates the old collection, but keeps the Items of the previous collection. The way that impl/memory was using SetCollection was more along the lines of GetOrCreate, which could cause corruption or other issues if two codepaths did SetCollection simultaneously. This fixes the corruption bug by removing SetCollection from the memStore interface and replaces it with a GetOrCreateCollection, which checks for the collection, and only calls SetCollection if it doesn't exist. As a bonus, this seems to give a slight performance speedup over the previous broken code. Additionally, this forces all uses of VisitItemsAscend to use a Snapshot, to avoid accidental modification of a Collection while its being iterated over, which can lead to the situation discussed above, or other nasty errors. Finally, this adds an optional 'gkvlite tracer' functionality which came in (extremely) handy for finding this bug. When given a folder, it will emit go-code-like invocations of the functions run on every collection, and includes enough information to reveal which functions are being called on the root collection v. snapshots, and if there are any overlapping VisitItemsAscend invocations, etc. R=dnj@chromium.org BUG=550684 Committed: https://github.com/luci/gae/commit/e6d5b5947c9808f2ae778947377c2ef068510b34

Patch Set 1 #

Total comments: 23

Patch Set 2 : fix comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+374 lines, -109 lines) Patch
M impl/memory/datastore.go View 1 chunk +1 line, -1 line 0 comments Download
M impl/memory/datastore_data.go View 16 chunks +19 lines, -28 lines 0 comments Download
M impl/memory/datastore_index.go View 7 chunks +16 lines, -15 lines 0 comments Download
M impl/memory/datastore_index_selection.go View 4 chunks +4 lines, -4 lines 0 comments Download
M impl/memory/datastore_index_test.go View 4 chunks +4 lines, -4 lines 0 comments Download
M impl/memory/datastore_query_execution.go View 5 chunks +6 lines, -6 lines 0 comments Download
M impl/memory/datastore_test.go View 1 chunk +1 line, -1 line 0 comments Download
M impl/memory/doc.go View 1 chunk +10 lines, -0 lines 0 comments Download
M impl/memory/gkvlite_iter.go View 2 chunks +5 lines, -1 line 0 comments Download
M impl/memory/gkvlite_iter_test.go View 2 chunks +6 lines, -3 lines 0 comments Download
A impl/memory/gkvlite_tracing_utils.go View 1 1 chunk +198 lines, -0 lines 0 comments Download
M impl/memory/gkvlite_utils.go View 1 2 chunks +98 lines, -40 lines 0 comments Download
M impl/memory/gkvlite_utils_test.go View 1 chunk +6 lines, -6 lines 0 comments Download

Messages

Total messages: 10 (3 generated)
iannucci
4 years, 8 months ago (2016-04-22 03:31:56 UTC) #1
iannucci
Example tracer output: coll3 := newMemStore() coll3_snap0 := coll3.Snapshot() coll3_656e74733a := coll3.GetOrCreateCollection("ents:") coll3_656e74733a.Get([]byte{0x88, 0x0, 0x1, ...
4 years, 8 months ago (2016-04-22 03:33:17 UTC) #2
dnj
Mostly looks good, a handful of comments. https://chromiumcodereview.appspot.com/1911263002/diff/1/impl/memory/gkvlite_tracing_utils.go File impl/memory/gkvlite_tracing_utils.go (right): https://chromiumcodereview.appspot.com/1911263002/diff/1/impl/memory/gkvlite_tracing_utils.go#newcode19 impl/memory/gkvlite_tracing_utils.go:19: var logMemCollectionFolder ...
4 years, 8 months ago (2016-04-22 06:09:45 UTC) #4
iannucci
PTAL https://chromiumcodereview.appspot.com/1911263002/diff/1/impl/memory/gkvlite_tracing_utils.go File impl/memory/gkvlite_tracing_utils.go (right): https://chromiumcodereview.appspot.com/1911263002/diff/1/impl/memory/gkvlite_tracing_utils.go#newcode19 impl/memory/gkvlite_tracing_utils.go:19: var logMemCollectionFolder = flag.String( On 2016/04/22 06:09:44, dnj ...
4 years, 8 months ago (2016-04-22 06:56:25 UTC) #5
dnj
lgtm
4 years, 8 months ago (2016-04-22 16:00:00 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1911263002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1911263002/20001
4 years, 8 months ago (2016-04-22 16:24:35 UTC) #8
commit-bot: I haz the power
4 years, 8 months ago (2016-04-22 16:29:51 UTC) #10
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://github.com/luci/gae/commit/e6d5b5947c9808f2ae778947377c2ef068510b34

Powered by Google App Engine
This is Rietveld 408576698