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

Unified Diff: base/debug/debugger_posix.cc

Issue 11362048: GTTF: Make Linux stack dump signal handler async-signal safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/stack_trace_posix.cc » ('j') | base/debug/stack_trace_posix.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/debugger_posix.cc
diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc
index 796b0e8c528dcd13f87296996b3a352764f74028..1f4610b8c5ecca82cae3e6d76ea7c54bdac45b6a 100644
--- a/base/debug/debugger_posix.cc
+++ b/base/debug/debugger_posix.cc
@@ -79,14 +79,19 @@ bool SpawnDebuggerOnProcess(unsigned process_id) {
// Based on Apple's recommended method as described in
// http://developer.apple.com/qa/qa2004/qa1361.html
bool BeingDebugged() {
+ // NOTE: This code MUST be async-signal safe (it's used by in-process
+ // stack dumping signal handler). NO malloc or stdio is allowed here.
+ // While some code used below may be async-signal unsafe, note how
jar (doing other things) 2012/11/02 02:36:57 Please be specific (don't ask me to find the offen
Paweł Hajdan Jr. 2012/11/06 17:58:46 Done.
+ // the result is cached. If this code is properly warmed-up early
+ // in the start-up process, it should be safe to use later.
+
// If the process is sandboxed then we can't use the sysctl, so cache the
// value.
static bool is_set = false;
static bool being_debugged = false;
- if (is_set) {
+ if (is_set)
return being_debugged;
- }
// Initialize mib, which tells sysctl what info we want. In this case,
// we're looking for information about a specific process ID.
@@ -141,6 +146,9 @@ bool BeingDebugged() {
// can't detach without forking(), and that's not so great.
// static
bool BeingDebugged() {
+ // NOTE: This code MUST be async-signal safe (it's used by in-process
+ // stack dumping signal handler). NO malloc or stdio is allowed here.
+
int status_fd = open("/proc/self/status", O_RDONLY);
if (status_fd == -1)
return false;
@@ -229,6 +237,9 @@ bool BeingDebugged() {
#endif
void BreakDebugger() {
+ // NOTE: This code MUST be async-signal safe (it's used by in-process
+ // stack dumping signal handler). NO malloc or stdio is allowed here.
+
DEBUG_BREAK();
#if defined(OS_ANDROID) && !defined(OFFICIAL_BUILD)
// For Android development we always build release (debug builds are
« no previous file with comments | « no previous file | base/debug/stack_trace_posix.cc » ('j') | base/debug/stack_trace_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698