commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r821695 - in /commons/sandbox/runtime/trunk/src: main/native/include/ main/native/os/unix/ main/native/shared/ main/native/test/ test/org/apache/commons/runtime/
Date Mon, 05 Oct 2009 06:32:33 GMT
Author: mturk
Date: Mon Oct  5 06:32:32 2009
New Revision: 821695

URL: http://svn.apache.org/viewvc?rev=821695&view=rev
Log:
Rewrite posix exceptions

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
    commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
    commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c
    commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr.h?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr.h Mon Oct  5 06:32:32 2009
@@ -173,6 +173,23 @@
 #include <io.h>
 #include <process.h>    /* getpid() */
 #include <sys/stat.h>
+#else
+/* Add POSIX specific includes
+ */
+#include <signal.h>
+#include <setjmp.h>
+#if HAVE_UCONTEXT_H
+#include <ucontext.h>
+#endif
+#if defined(SOLARIS22) && defined(HAS_NATIVE_THREADS)
+#include <thread.h>
+#define pthread_key_t       thread_key_t
+#define pthread_key_create  thr_key_create
+#define pthread_setspecific thr_setspecific
+#define pthread_getspecific thr_getspecific
+#else
+#include <pthread.h>
+#endif
 #endif
 
 /* JNI header */

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h Mon Oct  5 06:32:32
2009
@@ -18,7 +18,6 @@
 #define _ACR_ERROR_H
 
 #include "acr.h"
-#include "acr_tlsd.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -65,54 +64,64 @@
     ACR_EX_LEN
 } acr_trowclass_e;
 
-#if defined(ACR_WANT_MEMPROTECT) && defined(DEBUG)
+#if defined(DEBUG)
 #ifdef _MSC_VER
-#define ACR_TRY             __try
-#define ACR_CATCH()         __except(EXCEPTION_EXECUTE_HANDLER)
-
-#else
-#include <signal.h>
-#include <setjmp.h>
-#if HAVE_UCONTEXT_H
-#include <ucontext.h>
-#endif
-typedef void (_seh_handler_t)(int);
-#if HAVE_SIGSETJMP
-#define SEH_SETJMP(E)        sigsetjmp((E), 1)
-#define SEH_DOJUMP(E, V)     siglongjmp((E), (V))
-#else
-#define SEH_SETJMP(E)        setjmp((E))
-#define SEH_DOJUMP(E, V)     longjmp((E), (V))
-#endif
-static void _seh_handler(int val)
-{
-    acr_thread_local_t *tlsd = ACR_TLSD();
-    if (tlsd && (val == SIGSEGV || val == SIGBUS)) {
-        SEH_DOJUMP(tlsd->seh_jump, val);
-    }
-}
-
-#define ACR_TRY                                                               \
-    int _seh_error = 0;                                                       \
+#define __TRY              { __try
+#define __EXCEPT          __except(EXCEPTION_EXECUTE_HANDLER)
+#define __ENDTRY           }
+
+#else
+/* Use the thread safe signals by catching the
+ * SIGSEGV and SIGBUS.
+ * This is as close as we can emulate the undocumented
+ * Microsoft SEH.
+ * Anyhow the code is usable only in ceratin situations where
+ * those signals are known to get rised. Thus we enable the SEH
+ * only in DEBUG mode. Proper guarding should be done in
+ * Java code by making sure the params are valid. However
+ * the things like invalid pointers or double memory free
+ * cannot be effectively handled because the OS usually doesn't
+ * rise a signal, but rather corrupts the memory causing
+ * failures at some later point.
+ */
+extern pthread_key_t seh_ctxt_key;
+typedef struct acr_seh_ctxt_t {
+        int         init;
+        const char *file;
+        int         line;
+        sigjmp_buf  jump;
+} acr_seh_ctxt_t;
+#define __TRY                                                                 \
     {                                                                         \
-    acr_thread_local_t *_tlsd = ACR_TLSD();                                   \
-    _seh_handler_t* _org_sigseg_handler = signal(SIGSEGV, _seh_handler);      \
-    _seh_handler_t* _org_sigbus_handler = signal(SIGBUS,  _seh_handler);      \
-    if (_tlsd && (_seh_error = SEH_SETJMP(_tlsd->seh_jump)))                 
\
-            goto _seh_catch_block;
-
-#define ACR_CATCH()                                                           \
-_seh_catch_block:                                                             \
-    signal(SIGSEGV, _org_sigseg_handler);                                     \
-    signal(SIGBUS,  _org_sigbus_handler);                                     \
-    } if (_seh_error)
+        acr_seh_ctxt_t _seh_ctxt = { 0, __FILE__, __LINE__ };                 \
+        pthread_setspecific(seh_ctxt_key, &_seh_ctxt);                        \
+        for (;;) {                                                            \
+            if (_seh_ctxt.init)  {                                            \
+                do
+
+#define __EXCEPT                                                              \
+                while (0);                                                    \
+                break;                                                        \
+            } else {                                                          \
+                _seh_ctxt.init = 1;                                           \
+                if (sigsetjmp(_seh_ctxt.jump, 1) == 0) {                      \
+                    continue;                                                 \
+                } else
+
+#define __ENDTRY                                                              \
+            }                                                                 \
+            break;                                                            \
+        }                                                                     \
+        pthread_setspecific(seh_ctxt_key, NULL);                              \
+    }
 
 #endif
 #else
-#define ACR_TRY
-#define ACR_CATCH() if (0)
+#define __TRY       {
+#define __EXCEPT    if (0)
+#define __ENDTRY    }
 
-#endif /* HAVE_MEMPROTECT */
+#endif /* DEBUG */
 
 #define ACR_THROW_IO_IF_ERR(S)                                              \
     if ((S) && IS_VALID_HANDLE(_E)) {                                       \
@@ -1337,7 +1346,8 @@
                 || (s) == ERROR_BAD_NETPATH \
                 || (s) == ERROR_BAD_NET_NAME \
                 || (s) == ERROR_BAD_PATHNAME \
-                || (s) == ERROR_INVALID_DRIVE)
+                || (s) == ERROR_INVALID_DRIVE \
+                || (s) == ERROR_DIRECTORY)
 #define ACR_STATUS_IS_ENOSPC(s)         ((s) == ACR_ENOSPC \
                 || (s) == ERROR_DISK_FULL)
 #define ACR_STATUS_IS_ENOMEM(s)         ((s) == ACR_ENOMEM \

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_tlsd.h Mon Oct  5 06:32:32 2009
@@ -52,25 +52,6 @@
     JNIEnv         *env;
     unsigned int    id;
     int             jvm_attached;
-#if defined(DEBUG)
-#if defined(WIN32)
-    /* SEH requires no special TLSD data
-     * on Windows
-     */
-#else
-#if HAVE_UCONTEXT_H
-    /* TODO: Use setcontext instead jump
-     * However it just might be an overhead.
-     */
-    ucontext_t  seh_uctx;
-#endif
-#if HAVE_SIGSETJMP
-    sigjmp_buf  seh_jump;
-#else
-    jmp_buf     seh_jump;
-#endif /* HAVE_SIGSETJMP    */
-#endif /* WIN32             */
-#endif /* DEBUG             */
 };
 
 /**

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Mon Oct  5 06:32:32 2009
@@ -21,16 +21,6 @@
 #include "acr_tlsd.h"
 #include "acr_vm.h"
 
-#if defined(SOLARIS22) && defined(HAS_NATIVE_THREADS)
-#include <thread.h>
-#define pthread_key_t       thread_key_t
-#define pthread_key_create  thr_key_create
-#define pthread_setspecific thr_setspecific
-#define pthread_getspecific thr_getspecific
-#else
-#include <pthread.h>
-#endif
-
 /**
  * Posix main
  *

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c Mon Oct  5 06:32:32 2009
@@ -31,9 +31,122 @@
  * signals befre calling init.
  */
 static struct sigaction *_signalset[ACR_NUMSIG];
+
+#if defined(DEBUG)
+pthread_key_t seh_ctxt_key;
+static void seh_sig_handler(int sig)
+{
+    acr_seh_ctxt_t *ctxt = (acr_seh_ctxt_t *)pthread_getspecific(seh_ctxt_key);
+    if (sig == SIGSEGV || sig == SIGBUS) {
+        if (ctxt && ctxt->init) {
+            fprintf(stderr, "[error] Executing SEH handler for signal: %d (%s)\n",
+                    sig, ACR_SignalDescription(sig));
+            fprintf(stderr, "        Line: %d - %s\n", ctxt->line, ctxt->file);
+            fflush(stderr);
+            siglongjmp(ctxt->jump, 1);
+        }
+        else if (_signalset[sig]->sa_handler != SIG_DFL &&
+                 _signalset[sig]->sa_handler != SIG_IGN &&
+                 _signalset[sig]->sa_handler != SIG_ERR) {
+            /* This should invoke JVM crash report
+             */
+            (*_signalset[sig]->sa_handler)(sig);
+        }
+        else {
+            /* Not inside JVM.
+             * Print some warning and abort
+             */
+            fprintf(stderr, "[error] Cannot find default handler for signal '%s'\n",
+                    ACR_SignalDescription(sig));
+            fputs("        Aborting ...\n", stderr);
+            fflush(stderr);
+            abort();
+        }
+    }
+}
+
+/*
+ * 1. Signals SIGKILL, SIGSTOP cannot be blocked.
+ * 2. Signals SIGCONT, SIGTSTP, SIGTTIN, SIGTTOU are not blocked because
+ *    dealing with these signals is dangerous.
+ * 3. Signals SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGTRAP, SIGIOT, SIGEMT,
+ *    SIGBUS, SIGSYS, SIGSTKFLT are not blocked because these are synchronous
+ *    signals, which may require immediate intervention, otherwise the
+ *    process may starve.
+ */
+static int sig_blocked[] = {
+#ifdef SIGHUP
+    SIGHUP,
+#endif
+#ifdef SIGINT
+    SIGINT,
+#endif
+#ifdef SIGQUIT
+    SIGQUIT,
+#endif
+#ifdef SIGPIPE
+    SIGPIPE,
+#endif
+#ifdef SIGALRM
+    SIGALRM,
+#endif
+#ifdef SIGTERM
+    SIGTERM,
+#endif
+#ifdef SIGUSR1
+    SIGUSR1,
+#endif
+#ifdef SIGUSR2
+    SIGUSR2,
+#endif
+#ifdef SIGCHLD
+    SIGCHLD,
+#endif
+#ifdef SIGCLD
+    SIGCLD,
+#endif
+#ifdef SIGURG
+    SIGURG,
+#endif
+#ifdef SIGIO
+    SIGIO,
+#endif
+#ifdef SIGPOLL
+    SIGPOLL,
+#endif
+#ifdef SIGXCPU
+    SIGXCPU,
+#endif
+#ifdef SIGXFSZ
+    SIGXFSZ,
+#endif
+#ifdef SIGVTALRM
+    SIGVTALRM,
+#endif
+#ifdef SIGPROF
+    SIGPROF,
+#endif
+#ifdef SIGPWR
+    SIGPWR,
+#endif
+#ifdef SIGLOST
+    SIGLOST,
+#endif
+#ifdef SIGWINCH
+    SIGWINCH,
+#endif
+    -1
+};
+
+#endif
+
+static int initialized = 0;
 int acr_SignalsInit()
 {
     int i, rc = 0;
+
+    if (initialized++)
+        return 0;
     for (i = 0; i < ACR_NUMSIG; i++) {
         _signalset[i] = s_calloc(struct sigaction, 1);
         if (_signalset[i] == NULL)
@@ -61,6 +174,31 @@
             _signalset[i]->sa_handler = SIG_ERR;
         }
     }
+#if defined(DEBUG)
+    {
+        struct sigaction act;
+
+        if (pthread_key_create(&seh_ctxt_key, NULL))
+            return ACR_GET_OS_ERROR();
+        act.sa_handler = seh_sig_handler;
+        sigemptyset(&act.sa_mask);
+        act.sa_flags = 0;
+#ifdef SA_INTERRUPT
+        act.sa_flags |= SA_INTERRUPT;
+#endif
+        for (i = 0; sig_blocked[i] > 0; i++) {
+            /* Block most signals during SIGSEGV handling
+             */
+            sigaddset(&act.sa_mask, sig_blocked[i]);
+        }
+        /* Handle SIGSEGV signal
+         */
+        sigaction(SIGSEGV, &act, (struct sigaction *)NULL);
+#if defined(HPUX11) || defined(DARWIN)
+        sigaction(SIGBUS,  &act, (struct sigaction *)NULL);
+#endif
+    }
+#endif
     return rc;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Mon Oct  5 06:32:32 2009
@@ -18,7 +18,6 @@
 #include "acr_private.h"
 #include "acr_arch.h"
 #include "acr_memory.h"
-#define  ACR_WANT_MEMPROTECT
 #include "acr_error.h"
 #include "acr_pointer.h"
 #include "acr_vm.h"
@@ -479,12 +478,16 @@
         return NULL;
     }
     /* Copy the original content */
-    ACR_TRY {
+    __TRY
+    {
         memcpy(dp, sp + so, ss);
         po = ACR_NewBasicPointer(_E, dp, ss, memory_pointer_cleanup);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
     if (!po) {
         /* Destroy the the memory we failed to attach
          * to the new Pointer object.
@@ -520,11 +523,15 @@
     }
 
     /* Do a memcpy */
-    ACR_TRY {
+    __TRY
+    {
         memcpy(d + dn, s + sn, cs);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, move0)(ACR_JNISTDARGS, jobject src,
@@ -553,11 +560,15 @@
     }
 
     /* Do a memmove */
-    ACR_TRY {
+    __TRY
+    {
         memmove(d + dn, s + sn, cs);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, clear0)(ACR_JNISTDARGS, jobject dst,
@@ -581,11 +592,15 @@
         return;
     }
     /* Do a memset */
-    ACR_TRY {
+    __TRY
+    {
         memset(d + dn, 0, cs);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_JNI_EXPORT_DECLARE(void, Memory, set0)(ACR_JNISTDARGS, jobject dst,
@@ -609,11 +624,15 @@
         return;
     }
     /* Do a memset */
-    ACR_TRY {
+    __TRY
+    {
         memset(d + dn, c, cs);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_JNI_EXPORT_DECLARE(jbyteArray, Memory, array0)(ACR_JNISTDARGS, jobject ptr,

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/nbb.c Mon Oct  5 06:32:32 2009
@@ -24,8 +24,6 @@
 #include "acr_arch.h"
 #include "acr_clazz.h"
 #include "acr_pointer.h"
-
-#define  ACR_WANT_MEMPROTECT
 #include "acr_error.h"
 
 /**
@@ -414,14 +412,18 @@
          * Make sure you call Native.enableExceptionHandler() to
          * throw an exception instead.
          */
-        ACR_TRY {
+        __TRY
+        {
             x_free(mem);
-        } ACR_CATCH() {
+        }
+        __EXCEPT
+        {
             /* XXX: Unstable.
              * On linux this works only if MALLOC_CHECK_=1 envvar is set
              */
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, EFAULT);
         }
+        __ENDTRY
     }
     else {
         ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENULL,
@@ -464,11 +466,15 @@
         return;
     }
     if ((m = (*_E)->GetDirectBufferAddress(_E, bb))) {
-        ACR_TRY {
+        __TRY
+        {
             memset(m, c, (size_t)count);
-        } ACR_CATCH() {
+        }
+        __EXCEPT
+        {
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, EFAULT);
         }
+        __ENDTRY
     }
     else {
         ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENULL,
@@ -513,12 +519,16 @@
     }
     if ((s = (*_E)->GetDirectBufferAddress(_E, srcb))) {
         if ((d = (*_E)->GetDirectBufferAddress(_E, dstb))) {
-            ACR_TRY {
+            __TRY
+            {
                 memcpy((char *)d + (size_t)dsto, (char *)s + (size_t)srco,
                        (size_t)count);
-            } ACR_CATCH() {
+            }
+            __EXCEPT
+            {
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, EFAULT);
             }
+            __ENDTRY
         }
         else {
             ACR_ThrowException(_E, THROW_FMARK, ACR_EX_ENULL,
@@ -530,4 +540,3 @@
                            ACR_EISNULL);
     }
 }
-

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/pointer.c Mon Oct  5 06:32:32 2009
@@ -21,7 +21,6 @@
 
 #include "acr.h"
 #include "acr_private.h"
-#define  ACR_WANT_MEMPROTECT
 #include "acr_error.h"
 #include "acr_clazz.h"
 #include "acr_pointer.h"
@@ -180,44 +179,59 @@
     jint rv = 0;
     UNREFERENCED_O;
 
-    ACR_TRY {
+    __TRY
+    {
         rv = *(N2P(a, char *));
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
     return rv;
 }
 
 ACR_PTR_EXPORT_DECLARE(void, poke0)(ACR_JNISTDARGS, jniptr a, jint v)
 {
     UNREFERENCED_O;
-    ACR_TRY {
+    __TRY
+    {
         *(N2P(a, char *)) = (char)(v & 0xFF);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_PTR_EXPORT_DECLARE(void, copy0)(ACR_JNISTDARGS, jniptr s,
                                     jniptr d, jniptr l)
 {
     UNREFERENCED_O;
-    ACR_TRY {
+    __TRY
+    {
         memcpy(N2P(d, void *), N2P(s, const void *), (size_t)l);
-    } ACR_CATCH() {
+    }
+    __EXCEPT {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_PTR_EXPORT_DECLARE(void, move0)(ACR_JNISTDARGS, jniptr s,
                                     jniptr d, jniptr l)
 {
     UNREFERENCED_O;
-    ACR_TRY {
+    __TRY
+    {
         memmove(N2P(d, void *), N2P(s, const void *), (size_t)l);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_PTR_EXPORT_DECLARE(int, memcmp0)(ACR_JNISTDARGS, jniptr a,
@@ -225,14 +239,18 @@
 {
     int rv;
     UNREFERENCED_O;
-    ACR_TRY {
+    __TRY
+    {
         rv = memcmp(N2P(a, void *), N2P(b, const void *), (size_t)n);
         if (rv)
             rv = rv > 0 ? 1 : -1;
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, ACR_EFAULT);
         rv = -1;
     }
+    __ENDTRY
     return rv;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Mon Oct  5 06:32:32 2009
@@ -17,7 +17,6 @@
 #include "acr.h"
 #include "acr_private.h"
 #include "acr_arch.h"
-#define  ACR_WANT_MEMPROTECT
 #include "acr_error.h"
 #include "acr_string.h"
 #include "acr_memory.h"
@@ -444,12 +443,16 @@
 
 ACR_JNI_EXPORT_DECLARE(void, TestPrivate, test030)(ACR_JNISTDARGS, int d)
 {
-    ACR_TRY {
+    __TRY
+    {
         void *p = NULL;
         memset(p, 1, 100);
-    } ACR_CATCH() {
+    }
+    __EXCEPT
+    {
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ERUNTIME, EFAULT);
     }
+    __ENDTRY
 }
 
 ACR_JNI_EXPORT_DECLARE(jobjectArray, TestPrivate, test031)(ACR_JNISTDARGS, jstring s)

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=821695&r1=821694&r2=821695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Mon
Oct  5 06:32:32 2009
@@ -899,24 +899,26 @@
 
     // Some platforms become pretty unstable even on sucessful
     // handling of the SIGSEGV. The point is that this only
-    // helps in determining the cause of the fault,so that
+    // helps in determining the cause of the fault, so that
     // process can exit.
-    /*
+
     public void testMempotect()
         throws Throwable
     {
 
         if (Native.HAS_MAINTAINER_MODE) {
-            try {
-                test030(0);
-                fail("Exception not thrown");
-            } catch (Throwable t) {
-                assertSame("Wrong Exception class",
-                    java.lang.RuntimeException.class, t.getClass());
+            for (int i = 0; i < 10; i++) {
+                try {
+                    test030(0);
+                    fail("Exception not thrown");
+                } catch (Throwable t) {
+                    assertSame("Wrong Exception class",
+                        java.lang.RuntimeException.class, t.getClass());
+                }
             }
         }
     }
-    */
+
 
     public void testMszAnsi()
         throws Throwable



Mime
View raw message