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

Issue 18661009: Update ReadProcMaps() to reflect lack of atomicity when reading /proc/self/maps. (Closed)

Created:
7 years, 5 months ago by scherkus (not reviewing)
Modified:
7 years, 3 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org
Visibility:
Public.

Description

Update ReadProcMaps() to reflect lack of atomicity when reading /proc/self/maps. Reading from procfs returns at most a page-sized amount of data. If the process has a larger-than-page-sized /proc/self/maps, we cannot guarantee that the virtual memory table hasn't changed while reading the entire contents from procfs. In addition, ReadProcMaps() now stops reading as soon as it finds a gate VMA entry to workaround a scenario where the kernel would return duplicate entries (it turns out ThreadSanitizer v2 was very good at triggering said scenario). BUG=258451 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=221570

Patch Set 1 #

Total comments: 1

Patch Set 2 : Use std::string::resize() #

Total comments: 5

Patch Set 3 : check for gate vma #

Total comments: 2

Patch Set 4 : #

Total comments: 4

Patch Set 5 : fixes #

Total comments: 2

Patch Set 6 : for SPEED #

Total comments: 7

Patch Set 7 : nits #

Unified diffs Side-by-side diffs Delta from patch set Stats (+105 lines, -10 lines) Patch
M base/debug/proc_maps_linux.h View 1 2 3 4 5 1 chunk +34 lines, -0 lines 0 comments Download
M base/debug/proc_maps_linux.cc View 1 2 3 4 5 6 2 chunks +63 lines, -2 lines 0 comments Download
M base/debug/proc_maps_linux_unittest.cc View 1 2 3 4 2 chunks +8 lines, -8 lines 0 comments Download

Messages

Total messages: 22 (0 generated)
scherkus (not reviewing)
glider: here's my take at it mark: base/ OWNERS + peanut gallery I believe the ...
7 years, 5 months ago (2013-07-10 23:02:05 UTC) #1
Mark Mentovai
https://codereview.chromium.org/18661009/diff/2001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/2001/base/debug/proc_maps_linux.cc#newcode28 base/debug/proc_maps_linux.cc:28: enum { kLargeProcMapsSize = 256 * 1024 }; Why ...
7 years, 5 months ago (2013-07-11 03:47:49 UTC) #2
Alexander Potapenko
https://codereview.chromium.org/18661009/diff/2001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/2001/base/debug/proc_maps_linux.cc#newcode40 base/debug/proc_maps_linux.cc:40: return file_util::ReadFileToString(proc_maps_path, proc_maps); Maybe base::MemoryMappedFile could be used instead? ...
7 years, 5 months ago (2013-07-11 10:28:54 UTC) #3
Alexander Potapenko
https://codereview.chromium.org/18661009/diff/1/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/1/base/debug/proc_maps_linux.cc#newcode50 base/debug/proc_maps_linux.cc:50: read(fd, buffer.get() + offset, kMaxProcMapsSize - offset)); There must ...
7 years, 5 months ago (2013-07-11 10:47:23 UTC) #4
Mark Mentovai
Here’s the story… Both patch set 1 and patch set 2 aren’t thread-safe. But they ...
7 years, 5 months ago (2013-07-11 14:20:40 UTC) #5
scherkus (not reviewing)
On 2013/07/11 14:20:40, Mark Mentovai wrote: > Here’s the story… > > Both patch set ...
7 years, 5 months ago (2013-07-12 00:35:42 UTC) #6
Alexander Potapenko
We can try to stitch the information from several read() calls. E.g. if there's a ...
7 years, 5 months ago (2013-07-12 11:26:35 UTC) #7
Mark Mentovai
This is starting to get gross. The best I’m able to come up with that’s ...
7 years, 5 months ago (2013-07-12 14:57:10 UTC) #8
scherkus (not reviewing)
On 2013/07/12 14:57:10, Mark Mentovai wrote: > This is starting to get gross. > > ...
7 years, 5 months ago (2013-07-12 23:25:24 UTC) #9
Alexander Potapenko
https://codereview.chromium.org/18661009/diff/18001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/18001/base/debug/proc_maps_linux.cc#newcode59 base/debug/proc_maps_linux.cc:59: ssize_t bytes_read = HANDLE_EINTR(read(fd, buffer.get(), kBufferSize)); I wonder what ...
7 years, 5 months ago (2013-07-15 08:17:18 UTC) #10
Alexander Potapenko
Also, if that's a problem to find a gate VMA, maybe we could check that ...
7 years, 5 months ago (2013-07-15 08:20:43 UTC) #11
scherkus (not reviewing)
https://codereview.chromium.org/18661009/diff/18001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/18001/base/debug/proc_maps_linux.cc#newcode59 base/debug/proc_maps_linux.cc:59: ssize_t bytes_read = HANDLE_EINTR(read(fd, buffer.get(), kBufferSize)); On 2013/07/15 08:17:19, ...
7 years, 5 months ago (2013-07-15 17:46:55 UTC) #12
scherkus (not reviewing)
Finally got back to updating this... As discussed offline and in the bug... here's the ...
7 years, 3 months ago (2013-09-05 01:43:30 UTC) #13
Mark Mentovai
https://codereview.chromium.org/18661009/diff/26001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/26001/base/debug/proc_maps_linux.cc#newcode32 base/debug/proc_maps_linux.cc:32: return proc_maps->find("[vectors]", pos) != std::string::npos; Wanna look for the ...
7 years, 3 months ago (2013-09-05 16:31:17 UTC) #14
scherkus (not reviewing)
https://codereview.chromium.org/18661009/diff/26001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/26001/base/debug/proc_maps_linux.cc#newcode32 base/debug/proc_maps_linux.cc:32: return proc_maps->find("[vectors]", pos) != std::string::npos; On 2013/09/05 16:31:17, Mark ...
7 years, 3 months ago (2013-09-05 17:24:33 UTC) #15
Mark Mentovai
LGTM. The comment is optional. If you make the suggested change, I’ll do a quick ...
7 years, 3 months ago (2013-09-05 17:52:42 UTC) #16
scherkus (not reviewing)
https://codereview.chromium.org/18661009/diff/35001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/35001/base/debug/proc_maps_linux.cc#newcode58 base/debug/proc_maps_linux.cc:58: ssize_t bytes_read = HANDLE_EINTR(read(fd, buffer.get(), kBufferSize)); On 2013/09/05 17:52:43, ...
7 years, 3 months ago (2013-09-05 19:01:40 UTC) #17
Mark Mentovai
LGTM https://codereview.chromium.org/18661009/diff/48001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/48001/base/debug/proc_maps_linux.cc#newcode61 base/debug/proc_maps_linux.cc:61: void* buffer = &proc_maps->front() + pos; Simplify to ...
7 years, 3 months ago (2013-09-05 19:25:49 UTC) #18
scherkus (not reviewing)
https://codereview.chromium.org/18661009/diff/48001/base/debug/proc_maps_linux.cc File base/debug/proc_maps_linux.cc (right): https://codereview.chromium.org/18661009/diff/48001/base/debug/proc_maps_linux.cc#newcode61 base/debug/proc_maps_linux.cc:61: void* buffer = &proc_maps->front() + pos; On 2013/09/05 19:25:50, ...
7 years, 3 months ago (2013-09-05 19:54:51 UTC) #19
Mark Mentovai
LGTM! All done!
7 years, 3 months ago (2013-09-05 20:16:53 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/scherkus@chromium.org/18661009/55001
7 years, 3 months ago (2013-09-05 20:33:27 UTC) #21
commit-bot: I haz the power
7 years, 3 months ago (2013-09-06 05:07:52 UTC) #22
Message was sent while issue was closed.
Change committed as 221570

Powered by Google App Engine
This is Rietveld 408576698