Exit cleanly for the SRPC "log" requests instead of generating crash reports.

This is to avoid spamming the crash report server for
things like validation errors, DEP unsupported, "read
error", or no memory for address space of which
we already have UMA stats for. Of those, validation is
currently the lowest ranking one.

NaClLog(LOG_FATAL, ...) would have caused the code to
run a special "gNaClLogAbortBehavior" hook, which ends up
copying data to the renderer:
https://codereview.chromium.org/469423002/

This change downgrades from LOG_FATAL to LOG_ERROR,
exposes the hook, and manually calls the hook. It leaves other
types of NaClLog(LOG_FATAL, ...) alone and allows generating
a crash report and backtrace.

See Chrome's ServiceRuntime::ReapLogs for the source of
this RPC call:
https://code.google.com/p/chromium/codesearch#chromium/src/components/nacl/renderer/plugin/service_runtime.cc&sq=package:chromium&l=225&q=ReapLogs

BUG= https://code.google.com/p/chromium/issues/detail?id=405697

TEST=

(a) ./scons run_nacl_error_log_test (still runs the
hooks and aborts)

(b) patch into chrome and build/run browser_tests.

"NativeClient: Validation failure..." from NaClBrowserTestNewlib.BadNative

and

"NativeClient: Bad ELF header magic number" from NaClBrowserTestNewlib.Bad

still show up.

(c) Also check manually check the javascript console to see the "reap logs"
and other buffered logs show up.

Review URL: https://codereview.chromium.org/997683002
diff --git a/src/shared/platform/nacl_log.c b/src/shared/platform/nacl_log.c
index 2e6e4d1..5f172a3 100644
--- a/src/shared/platform/nacl_log.c
+++ b/src/shared/platform/nacl_log.c
@@ -352,8 +352,9 @@
 #ifdef __COVERITY__
         NaClAbort();  /* help coverity figure out that this is the default */
 #else
-        (*gNaClLogAbortBehavior)();
+        NaClLogRunAbortBehavior();
 #endif
+        /* The abort behavior hook may not abort, so abort here in case. */
         NaClAbort();
       }
       break;
@@ -716,3 +717,7 @@
   gNaClLogAbortBehavior = fn;
   NaClXMutexUnlock(&log_mu);
 }
+
+void NaClLogRunAbortBehavior(void) {
+  (*gNaClLogAbortBehavior)();
+}
diff --git a/src/shared/platform/nacl_log.h b/src/shared/platform/nacl_log.h
index ea9a514..619d937 100644
--- a/src/shared/platform/nacl_log.h
+++ b/src/shared/platform/nacl_log.h
@@ -370,6 +370,11 @@
  */
 void NaClLogSetAbortBehavior(void (*fn)(void));
 
+/*
+ * Run the current abort behavior hook.
+ */
+void NaClLogRunAbortBehavior(void);
+
 EXTERN_C_END
 
 #endif  /* NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_LOG_H__ */
diff --git a/src/trusted/service_runtime/nacl_error_log_hook.c b/src/trusted/service_runtime/nacl_error_log_hook.c
index 40c60cb..f8b5d1a 100644
--- a/src/trusted/service_runtime/nacl_error_log_hook.c
+++ b/src/trusted/service_runtime/nacl_error_log_hook.c
@@ -34,7 +34,6 @@
     (*g_NaCl_log_abort_fn)(g_NaCl_log_abort_state,
                            log_data, log_data_bytes);
   }
-  NaClAbort();
 }
 
 void NaClErrorLogHookInit(void (*hook)(void *state,
diff --git a/src/trusted/service_runtime/nacl_secure_service.c b/src/trusted/service_runtime/nacl_secure_service.c
index 9e5e315..e0e3669 100644
--- a/src/trusted/service_runtime/nacl_secure_service.c
+++ b/src/trusted/service_runtime/nacl_secure_service.c
@@ -257,6 +257,19 @@
   UNREFERENCED_PARAMETER(out_args);
 
   NaClLog(5, "NaClSecureChannelLogRpc\n");
+  if (LOG_FATAL == severity) {
+    /*
+     * Do not actually abort due to LOG_FATAL. SRPC is deprecated and the
+     * only remaining user of this Log RPC corresponds to fairly benign
+     * errors. Also, at this point the backtraces will not be terribly
+     * interesting. Therefore, avoid spamming the crash report counter
+     * for such errors and exit cleanly. Run the abort hook as well,
+     * to flush the logs.
+     */
+    NaClLog(LOG_ERROR, "%s\n", msg);
+    NaClLogRunAbortBehavior();
+    NaClExit(1);
+  }
   NaClLog(severity, "%s\n", msg);
   NaClLog(5, "NaClSecureChannelLogRpc\n");
   rpc->result = NACL_SRPC_RESULT_OK;