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

Side by Side Diff: breakpad/linux/exception_handler.cc

Issue 115955: Point the child stack at the top-most address rather than the bottom-most add... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« 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) 2009, Google Inc. 1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include <signal.h> 72 #include <signal.h>
73 #include <stdio.h> 73 #include <stdio.h>
74 #include <sys/mman.h> 74 #include <sys/mman.h>
75 #include <sys/signal.h> 75 #include <sys/signal.h>
76 #include <sys/syscall.h> 76 #include <sys/syscall.h>
77 #include <sys/ucontext.h> 77 #include <sys/ucontext.h>
78 #include <sys/user.h> 78 #include <sys/user.h>
79 #include <sys/wait.h> 79 #include <sys/wait.h>
80 #include <unistd.h> 80 #include <unistd.h>
81 81
82 #include "breakpad/linux/linux_libc_support.h"
82 #include "breakpad/linux/linux_syscall_support.h" 83 #include "breakpad/linux/linux_syscall_support.h"
83 #include "breakpad/linux/memory.h" 84 #include "breakpad/linux/memory.h"
84 #include "breakpad/linux/minidump_writer.h" 85 #include "breakpad/linux/minidump_writer.h"
85 #include "common/linux/guid_creator.h" 86 #include "common/linux/guid_creator.h"
86 87
87 // A wrapper for the tgkill syscall: send a signal to a specific thread. 88 // A wrapper for the tgkill syscall: send a signal to a specific thread.
88 static int tgkill(pid_t tgid, pid_t tid, int sig) { 89 static int tgkill(pid_t tgid, pid_t tid, int sig) {
89 syscall(__NR_tgkill, tgid, tid, sig); 90 syscall(__NR_tgkill, tgid, tid, sig);
90 } 91 }
91 92
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 260
260 CrashContext context; 261 CrashContext context;
261 memcpy(&context.siginfo, info, sizeof(siginfo_t)); 262 memcpy(&context.siginfo, info, sizeof(siginfo_t));
262 memcpy(&context.context, uc, sizeof(struct ucontext)); 263 memcpy(&context.context, uc, sizeof(struct ucontext));
263 context.tid = sys_gettid(); 264 context.tid = sys_gettid();
264 265
265 if (crash_handler_ && crash_handler_(&context, sizeof(context), 266 if (crash_handler_ && crash_handler_(&context, sizeof(context),
266 callback_context_)) 267 callback_context_))
267 return true; 268 return true;
268 269
270 static const unsigned kChildStackSize = 8000;
269 PageAllocator allocator; 271 PageAllocator allocator;
270 void* const stack = allocator.Alloc(8000); 272 uint8_t* stack = (uint8_t*) allocator.Alloc(kChildStackSize);
273 if (!stack)
274 return false;
275 // clone() needs the top-most address. (scrub just to be safe)
276 stack += kChildStackSize;
277 my_memset(stack - 16, 0, 16);
271 278
272 ThreadArgument thread_arg; 279 ThreadArgument thread_arg;
273 thread_arg.handler = this; 280 thread_arg.handler = this;
274 thread_arg.pid = getpid(); 281 thread_arg.pid = getpid();
275 thread_arg.context = &context; 282 thread_arg.context = &context;
276 thread_arg.context_size = sizeof(context); 283 thread_arg.context_size = sizeof(context);
277 284
278 const pid_t child = sys_clone( 285 const pid_t child = sys_clone(
279 ThreadEntry, stack, CLONE_FILES | CLONE_FS | CLONE_UNTRACED, 286 ThreadEntry, stack, CLONE_FILES | CLONE_FS | CLONE_UNTRACED,
280 &thread_arg, NULL, NULL, NULL); 287 &thread_arg, NULL, NULL, NULL);
(...skipping 20 matching lines...) Expand all
301 308
302 // This function runs in a compromised context: see the top of the file. 309 // This function runs in a compromised context: see the top of the file.
303 // Runs on the cloned process. 310 // Runs on the cloned process.
304 bool ExceptionHandler::DoDump(pid_t crashing_process, const void* context, 311 bool ExceptionHandler::DoDump(pid_t crashing_process, const void* context,
305 size_t context_size) { 312 size_t context_size) {
306 return google_breakpad::WriteMinidump( 313 return google_breakpad::WriteMinidump(
307 next_minidump_path_c_, crashing_process, context, context_size); 314 next_minidump_path_c_, crashing_process, context, context_size);
308 } 315 }
309 316
310 } // namespace google_breakpad 317 } // namespace google_breakpad
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