From 93257311a12637bd8528171617cb9845c5abd36c Mon Sep 17 00:00:00 2001
From: "mark@chromium.org"
 <mark@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>
Date: Fri, 26 Aug 2011 22:29:33 +0000
Subject: [PATCH] Fix a Breakpad crash during teardown when
 USE_PROTECTED_ALLOCATIONS is in effect.

BUG=none
TEST=Apple Crash Reporter logs from processes in which Breakpad handles the
     crash should point the finger at the actual crash source, not the
     Breakpad thread's attempt to write to unwritable memory.
Review URL: http://breakpad.appspot.com/301001

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@828 4c0a9323-5329-0410-9bdc-e9ce6186880e
---
 src/client/mac/handler/exception_handler.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/client/mac/handler/exception_handler.cc b/src/client/mac/handler/exception_handler.cc
index a6786fa1..d4cd43d5 100644
--- a/src/client/mac/handler/exception_handler.cc
+++ b/src/client/mac/handler/exception_handler.cc
@@ -593,6 +593,14 @@ void *ExceptionHandler::WaitForMessage(void *exception_handler_class) {
         self->WriteMinidumpWithException(receive.exception, receive.code[0],
                                          subcode, receive.thread.name, true);
 
+#if USE_PROTECTED_ALLOCATIONS
+        // This may have become protected again within
+        // WriteMinidumpWithException, but it needs to be unprotected for
+        // UninstallHandler.
+        if(gBreakpadAllocator)
+          gBreakpadAllocator->Unprotect();
+#endif
+
         self->UninstallHandler(true);
 
 #if USE_PROTECTED_ALLOCATIONS