Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DEE3210EB4 for ; Mon, 3 Feb 2014 16:12:50 +0000 (UTC) Received: (qmail 84245 invoked by uid 500); 3 Feb 2014 16:12:50 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 84214 invoked by uid 500); 3 Feb 2014 16:12:50 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 84200 invoked by uid 99); 3 Feb 2014 16:12:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2014 16:12:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Feb 2014 16:12:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7F7AD238889B; Mon, 3 Feb 2014 16:12:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1563971 - /subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Date: Mon, 03 Feb 2014 16:12:26 -0000 To: commits@subversion.apache.org From: brane@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140203161226.7F7AD238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: brane Date: Mon Feb 3 16:12:26 2014 New Revision: 1563971 URL: http://svn.apache.org/r1563971 Log: Added a malfunction handler to the JavaHL native implementation that in most cases causes a SEGV, or returns an error, instaed of calling abort(). Aborting prevents the JVM from creating a crash log file. * subversion/bindings/javahl/native/JNIUtil.cpp: Include svn_error.h. (gentle_crash_write_loc): New; volatile NULL pointer. (gently_crash_the_jvm): New; malfunction handler. (JNIUtil::JNIGlobalInit): Register gently_crash_the_jvm(). Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1563971&r1=1563970&r2=1563971&view=diff ============================================================================== --- subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp (original) +++ subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Mon Feb 3 16:12:26 2014 @@ -46,6 +46,7 @@ #include #include "svn_pools.h" +#include "svn_error.h" #include "svn_fs.h" #include "svn_ra.h" #include "svn_utf.h" @@ -117,6 +118,33 @@ bool initialize_jni_util(JNIEnv *env) return JNIUtil::JNIGlobalInit(env); } +namespace { + +volatile apr_int32_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 writing to the zero page + *gentle_crash_write_loc = 0xdeadbeef; + } + + // 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. @@ -244,6 +272,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; }