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

Side by Side Diff: base/memory/shared_memory_win.cc

Issue 2005853003: base: Add debugging to track down CreateFileMapping() errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/debug/alias.h"
12 #include "base/debug/dump_without_crashing.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
13 #include "base/rand_util.h" 15 #include "base/rand_util.h"
14 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
16 18
17 namespace { 19 namespace {
18 20
19 // Errors that can occur during Shared Memory construction. 21 // Errors that can occur during Shared Memory construction.
20 // These match tools/metrics/histograms/histograms.xml. 22 // These match tools/metrics/histograms/histograms.xml.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // 103 //
102 // By removing all access control permissions of a file mapping immediately 104 // By removing all access control permissions of a file mapping immediately
103 // after creation, ::DuplicateHandle() effectively only copies the file 105 // after creation, ::DuplicateHandle() effectively only copies the file
104 // permissions. 106 // permissions.
105 HANDLE CreateFileMappingWithReducedPermissions(SECURITY_ATTRIBUTES* sa, 107 HANDLE CreateFileMappingWithReducedPermissions(SECURITY_ATTRIBUTES* sa,
106 size_t rounded_size, 108 size_t rounded_size,
107 LPCWSTR name) { 109 LPCWSTR name) {
108 HANDLE h = CreateFileMapping(INVALID_HANDLE_VALUE, sa, PAGE_READWRITE, 0, 110 HANDLE h = CreateFileMapping(INVALID_HANDLE_VALUE, sa, PAGE_READWRITE, 0,
109 static_cast<DWORD>(rounded_size), name); 111 static_cast<DWORD>(rounded_size), name);
110 if (!h) { 112 if (!h) {
113 // Debugging to help track down https://crbug.com/585013
114 DWORD last_error = ::GetLastError();
115 base::debug::Alias(&last_error);
116 base::debug::DumpWithoutCrashing();
Nico 2016/05/24 00:22:13 is this code perf-sensitive? Should this just be f
erikchen 2016/05/24 00:41:20 This is perf-sensitive, but shouldn't be hit often
117
111 LogError(CREATE_FILE_MAPPING_FAILURE); 118 LogError(CREATE_FILE_MAPPING_FAILURE);
112 return nullptr; 119 return nullptr;
113 } 120 }
114 121
115 HANDLE h2; 122 HANDLE h2;
116 BOOL success = ::DuplicateHandle( 123 BOOL success = ::DuplicateHandle(
117 GetCurrentProcess(), h, GetCurrentProcess(), &h2, 124 GetCurrentProcess(), h, GetCurrentProcess(), &h2,
118 FILE_MAP_READ | FILE_MAP_WRITE | SECTION_QUERY, FALSE, 0); 125 FILE_MAP_READ | FILE_MAP_WRITE | SECTION_QUERY, FALSE, 0);
119 BOOL rv = ::CloseHandle(h); 126 BOOL rv = ::CloseHandle(h);
120 DCHECK(rv); 127 DCHECK(rv);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 ::CloseHandle(mapped_file_); 390 ::CloseHandle(mapped_file_);
384 mapped_file_ = NULL; 391 mapped_file_ = NULL;
385 } 392 }
386 } 393 }
387 394
388 SharedMemoryHandle SharedMemory::handle() const { 395 SharedMemoryHandle SharedMemory::handle() const {
389 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); 396 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId());
390 } 397 }
391 398
392 } // namespace base 399 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698