You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2016/01/15 13:11:43 UTC

svn commit: r1724784 - in /subversion/trunk/subversion/libsvn_subr: pool.c win32_crashrpt.c

Author: kotkov
Date: Fri Jan 15 12:11:43 2016
New Revision: 1724784

URL: http://svn.apache.org/viewvc?rev=1724784&view=rev
Log:
Provide a way to distinguish the out-of-memory error from abort() on Windows.

There are multiple reasons why an abort() could be called in our code.  Make
crashing due to out-of-memory conditions use a specific exception code, so
that we would be able to distinguish it from, e.g., crashing due to a failed
SVN_ERR_ASSERT().

* subversion/libsvn_subr/pool.c
  (abort_on_pool_failure): Raise STATUS_NO_MEMORY on Windows.

* subversion/libsvn_subr/win32_crashrpt.c
  (exception_string): Unroll the part of the stringifying macro.  Handle
   STATUS_NO_MEMORY in this helper for our unhandled exception filter.

Modified:
    subversion/trunk/subversion/libsvn_subr/pool.c
    subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c

Modified: subversion/trunk/subversion/libsvn_subr/pool.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/pool.c?rev=1724784&r1=1724783&r2=1724784&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/pool.c (original)
+++ subversion/trunk/subversion/libsvn_subr/pool.c Fri Jan 15 12:11:43 2016
@@ -54,6 +54,13 @@ abort_on_pool_failure(int retcode)
   /* Don't translate this string! It requires memory allocation to do so!
      And we don't have any of it... */
   printf("libsvn: Out of memory - terminating application.\n");
+
+#ifdef WIN32
+  /* Provide a way to distinguish the out-of-memory error from abort(). */
+  if (retcode == APR_ENOMEM)
+    RaiseException(STATUS_NO_MEMORY, 0, 0, NULL);
+#endif
+
   abort();
   return 0; /* not reached */
 }

Modified: subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c?rev=1724784&r1=1724783&r2=1724784&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c (original)
+++ subversion/trunk/subversion/libsvn_subr/win32_crashrpt.c Fri Jan 15 12:11:43 2016
@@ -84,32 +84,33 @@ convert_wbcs_to_ansi(const wchar_t *str)
 static const char *
 exception_string(int exception)
 {
-#define EXCEPTION(x) case EXCEPTION_##x: return (#x);
+#define EXCEPTION(x) case x: return (#x);
 
   switch (exception)
     {
-      EXCEPTION(ACCESS_VIOLATION)
-      EXCEPTION(DATATYPE_MISALIGNMENT)
-      EXCEPTION(BREAKPOINT)
-      EXCEPTION(SINGLE_STEP)
-      EXCEPTION(ARRAY_BOUNDS_EXCEEDED)
-      EXCEPTION(FLT_DENORMAL_OPERAND)
-      EXCEPTION(FLT_DIVIDE_BY_ZERO)
-      EXCEPTION(FLT_INEXACT_RESULT)
-      EXCEPTION(FLT_INVALID_OPERATION)
-      EXCEPTION(FLT_OVERFLOW)
-      EXCEPTION(FLT_STACK_CHECK)
-      EXCEPTION(FLT_UNDERFLOW)
-      EXCEPTION(INT_DIVIDE_BY_ZERO)
-      EXCEPTION(INT_OVERFLOW)
-      EXCEPTION(PRIV_INSTRUCTION)
-      EXCEPTION(IN_PAGE_ERROR)
-      EXCEPTION(ILLEGAL_INSTRUCTION)
-      EXCEPTION(NONCONTINUABLE_EXCEPTION)
-      EXCEPTION(STACK_OVERFLOW)
-      EXCEPTION(INVALID_DISPOSITION)
-      EXCEPTION(GUARD_PAGE)
-      EXCEPTION(INVALID_HANDLE)
+      EXCEPTION(EXCEPTION_ACCESS_VIOLATION)
+      EXCEPTION(EXCEPTION_DATATYPE_MISALIGNMENT)
+      EXCEPTION(EXCEPTION_BREAKPOINT)
+      EXCEPTION(EXCEPTION_SINGLE_STEP)
+      EXCEPTION(EXCEPTION_ARRAY_BOUNDS_EXCEEDED)
+      EXCEPTION(EXCEPTION_FLT_DENORMAL_OPERAND)
+      EXCEPTION(EXCEPTION_FLT_DIVIDE_BY_ZERO)
+      EXCEPTION(EXCEPTION_FLT_INEXACT_RESULT)
+      EXCEPTION(EXCEPTION_FLT_INVALID_OPERATION)
+      EXCEPTION(EXCEPTION_FLT_OVERFLOW)
+      EXCEPTION(EXCEPTION_FLT_STACK_CHECK)
+      EXCEPTION(EXCEPTION_FLT_UNDERFLOW)
+      EXCEPTION(EXCEPTION_INT_DIVIDE_BY_ZERO)
+      EXCEPTION(EXCEPTION_INT_OVERFLOW)
+      EXCEPTION(EXCEPTION_PRIV_INSTRUCTION)
+      EXCEPTION(EXCEPTION_IN_PAGE_ERROR)
+      EXCEPTION(EXCEPTION_ILLEGAL_INSTRUCTION)
+      EXCEPTION(EXCEPTION_NONCONTINUABLE_EXCEPTION)
+      EXCEPTION(EXCEPTION_STACK_OVERFLOW)
+      EXCEPTION(EXCEPTION_INVALID_DISPOSITION)
+      EXCEPTION(EXCEPTION_GUARD_PAGE)
+      EXCEPTION(EXCEPTION_INVALID_HANDLE)
+      EXCEPTION(STATUS_NO_MEMORY)
 
       default:
         return "UNKNOWN_ERROR";