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

Side by Side Diff: chrome/browser/chromeos/libc_close_tracking.cc

Issue 2723063002: ChromeOS: Do not use TraceStackFramePointers() with MSAN. (Closed)
Patch Set: Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <errno.h> 5 #include <errno.h>
6 #include <sys/syscall.h> 6 #include <sys/syscall.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const int ret = IGNORE_EINTR(syscall(SYS_close, fd)); 112 const int ret = IGNORE_EINTR(syscall(SYS_close, fd));
113 // Captures errno and restores it later in case it is changed. 113 // Captures errno and restores it later in case it is changed.
114 const ErrnoCapture close_errno; 114 const ErrnoCapture close_errno;
115 115
116 // Return if tracking is not enabled for the current process. 116 // Return if tracking is not enabled for the current process.
117 if (!g_stack_tracker || !g_stack_tracker->ShouldTrack()) 117 if (!g_stack_tracker || !g_stack_tracker->ShouldTrack())
118 return ret; 118 return ret;
119 119
120 // Capture stack for successful close. 120 // Capture stack for successful close.
121 if (ret == 0) { 121 if (ret == 0) {
122 #if HAVE_TRACE_STACK_FRAME_POINTERS 122 #if HAVE_TRACE_STACK_FRAME_POINTERS && !defined(MEMORY_SANITIZER)
123 // Use TraceStackFramePointers because the backtrack() based default 123 // Use TraceStackFramePointers because the backtrack() based default
124 // capturing gets only the last stack frame and is not useful. 124 // capturing gets only the last stack frame and is not useful.
125 // With the exception of when MSAN is enabled. See comments for why
126 // StackTraceTest.TraceStackFramePointers is disabled in MSAN builds.
125 const void* frames[64]; 127 const void* frames[64];
126 const size_t frame_count = 128 const size_t frame_count =
127 base::debug::TraceStackFramePointers(frames, arraysize(frames), 0); 129 base::debug::TraceStackFramePointers(frames, arraysize(frames), 0);
128 g_stack_tracker->SetStack(fd, base::debug::StackTrace(frames, frame_count)); 130 g_stack_tracker->SetStack(fd, base::debug::StackTrace(frames, frame_count));
129 #else 131 #else
130 // Use default StackTrace when TraceStackFramePointers is not available. 132 // Use default StackTrace when TraceStackFramePointers is not available.
131 // Hopefully it will capture something useful. 133 // Hopefully it will capture something useful.
132 g_stack_tracker->SetStack(fd, base::debug::StackTrace()); 134 g_stack_tracker->SetStack(fd, base::debug::StackTrace());
133 #endif 135 #endif
134 return ret; 136 return ret;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 const base::debug::StackTrace* GetLastCloseStackForTest(int fd) { 178 const base::debug::StackTrace* GetLastCloseStackForTest(int fd) {
177 return g_stack_tracker ? g_stack_tracker->GetStack(fd) : nullptr; 179 return g_stack_tracker ? g_stack_tracker->GetStack(fd) : nullptr;
178 } 180 }
179 181
180 void SetCloseTrackingIgnorePidForTest(bool ignore_pid) { 182 void SetCloseTrackingIgnorePidForTest(bool ignore_pid) {
181 DCHECK(g_stack_tracker); 183 DCHECK(g_stack_tracker);
182 g_stack_tracker->set_ignore_pid(ignore_pid); 184 g_stack_tracker->set_ignore_pid(ignore_pid);
183 } 185 }
184 186
185 } // namespace chromeos 187 } // namespace chromeos
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