You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/02/05 04:20:43 UTC
svn commit: r1564614 - in
/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl: ./
native/JNIUtil.cpp
Author: brane
Date: Wed Feb 5 03:20:43 2014
New Revision: 1564614
URL: http://svn.apache.org/r1564614
Log:
On the javahl-1.8-extensions branch: sync JavaHL with trunk to r1564612.
Modified:
subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/ (props changed)
subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/JNIUtil.cpp
Propchange: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/
------------------------------------------------------------------------------
Merged /subversion/trunk/subversion/bindings/javahl:r1563141-1564612
Modified: subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/JNIUtil.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1564614&r1=1564613&r2=1564614&view=diff
==============================================================================
--- subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/JNIUtil.cpp (original)
+++ subversion/branches/javahl-1.8-extensions/subversion/bindings/javahl/native/JNIUtil.cpp Wed Feb 5 03:20:43 2014
@@ -46,6 +46,7 @@
#include <apr_time.h>
#include "svn_pools.h"
+#include "svn_error.h"
#include "svn_fs.h"
#include "svn_ra.h"
#include "svn_utf.h"
@@ -125,6 +126,34 @@ bool initialize_jni_util(JNIEnv *env)
return JNIUtil::JNIGlobalInit(env);
}
+namespace {
+
+volatile svn_atomic_t *gentle_crash_write_loc = NULL;
+
+svn_error_t *
+gently_crash_the_jvm(svn_boolean_t can_return,
+ const char *file, int line, const char *expr)
+{
+ if (!can_return)
+ {
+ // Try not to abort; aborting prevents the JVM from creating
+ // a crash log, which is oh so useful for debugging.
+ // We can't just raise a SEGV signal, either, because it will
+ // be not be caught in the context that we're interested in
+ // getting the stack trace from.
+
+ // Try reading from and writing to the zero page
+ const svn_atomic_t zeropage = svn_atomic_read(gentle_crash_write_loc);
+ svn_atomic_set(gentle_crash_write_loc, zeropage);
+ }
+
+ // Forward to the standard malfunction handler, which does call
+ // abort when !can_return; this will only happen if the write to the
+ // zero page did not cause a SEGV.
+ return svn_error_raise_on_malfunction(can_return, file, line, expr);
+}
+} // Anonymous namespace
+
/**
* Initialize the environment for all requests.
* This method must be called in a single-threaded context.
@@ -260,6 +289,10 @@ bool JNIUtil::JNIGlobalInit(JNIEnv *env)
if (isExceptionThrown())
return false;
+ // Set a malfunction handler that tries not to call abort, because
+ // that would prevent the JVM from creating a crash and stack log file.
+ svn_error_set_malfunction_handler(gently_crash_the_jvm);
+
return true;
}