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

Issue 2533303005: VM: Fix memory leak during shutdown (Closed)

Created:
4 years ago by kustermann
Modified:
4 years ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

VM: Fix memory leak during shutdown The way runtime/platform/hashmap.h:HashMap was implemented so far did not allow deleting elements while iterating over the map. If one iterated like this HashMap::Entry* cursor = map.Start(); while (cursor != NULL) { if (cond) { map.Remove(cursor->key, cursor->hash); } cursor = map.Next(cursor); } Then the iteration `cursor` will skip elements. This is due to the fact that `HashMap::Remove()` is left-rotating elements in certain cases and `HashMap::Next()` will unconditionally advance to the next position in the backing store. PROBLEM IS: There was existing code which did remove elements while iterating over a HashMap. R=fschneider@google.com Committed: https://github.com/dart-lang/sdk/commit/d822f36f154340f286efe6df9abb17007c1a4d79

Patch Set 1 #

Total comments: 8

Patch Set 2 : adressed comments #

Patch Set 3 : Simplify socket.cc by not updating hashmaps during shutdown #

Unified diffs Side-by-side diffs Delta from patch set Stats (+109 lines, -27 lines) Patch
M runtime/bin/hashmap_test.cc View 1 2 2 chunks +44 lines, -1 line 0 comments Download
M runtime/bin/socket.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M runtime/bin/socket.cc View 1 2 4 chunks +27 lines, -23 lines 0 comments Download
M runtime/platform/hashmap.h View 1 chunk +20 lines, -0 lines 0 comments Download
M runtime/platform/hashmap.cc View 1 2 chunks +17 lines, -2 lines 0 comments Download

Messages

Total messages: 13 (4 generated)
kustermann
4 years ago (2016-11-30 12:38:20 UTC) #2
kustermann
Just to clarify: The SEGGFAULTS have been already fixed. This issue here is not really ...
4 years ago (2016-11-30 12:41:46 UTC) #3
Vyacheslav Egorov (Google)
https://codereview.chromium.org/2533303005/diff/1/runtime/bin/socket.cc File runtime/bin/socket.cc (right): https://codereview.chromium.org/2533303005/diff/1/runtime/bin/socket.cc#newcode207 runtime/bin/socket.cc:207: bool ListeningSocketRegistry::CloseOneSafe(OSSocket* os_socket, I suggest a much simple approach: ...
4 years ago (2016-11-30 12:41:57 UTC) #4
Florian Schneider
Please add a regression test for this. Can your approach end up visiting some elements ...
4 years ago (2016-11-30 17:59:15 UTC) #5
Florian Schneider
I answered my own previous questions. Here some comments: https://codereview.chromium.org/2533303005/diff/1/runtime/platform/hashmap.cc File runtime/platform/hashmap.cc (right): https://codereview.chromium.org/2533303005/diff/1/runtime/platform/hashmap.cc#newcode110 runtime/platform/hashmap.cc:110: ...
4 years ago (2016-11-30 18:08:42 UTC) #6
kustermann
I could also just do the simple thing slava suggested: At cleanup time, just loop ...
4 years ago (2016-11-30 21:27:15 UTC) #7
Florian Schneider
Lgtm. If you follow Slava's approach, make sure to still add the comment about using ...
4 years ago (2016-11-30 21:51:48 UTC) #8
kustermann
Thanks for the review!
4 years ago (2016-11-30 22:48:59 UTC) #11
kustermann
4 years ago (2016-11-30 22:52:13 UTC) #13
Message was sent while issue was closed.
Committed patchset #3 (id:60001) manually as
d822f36f154340f286efe6df9abb17007c1a4d79 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698