Make Objective-C exceptions non-fatal by default on Mac OS X. b=486574 r=roc sr=bz
authorJosh Aas <joshmoz@gmail.com>
Wed, 20 May 2009 11:53:24 -0400
changeset 28645 a071dfefae96a02c043f1eb23d75e6dd5abd5604
parent 28644 b99d3379a6a81b9c83acc08483b6c86c3b4fdd1d
child 28646 13b38e2a54eeced447920ba49c80d2e3ca3b6e61
push idunknown
push userunknown
push dateunknown
reviewersroc, bz
bugs486574
milestone1.9.2a1pre
Make Objective-C exceptions non-fatal by default on Mac OS X. b=486574 r=roc sr=bz
xpcom/base/nsObjCExceptions.h
--- a/xpcom/base/nsObjCExceptions.h
+++ b/xpcom/base/nsObjCExceptions.h
@@ -51,16 +51,22 @@
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #endif
 
 #include <unistd.h>
 #include <signal.h>
 #include "nsError.h"
 
+/* NOTE: Macros that claim to abort no longer abort, see bug 486574.
+ * If you actually want to log and abort, call "nsObjCExceptionLogAbort"
+ * from an exception handler. At some point we will fix this by replacing
+ * all macros in the tree with appropriately-named macros.
+ */
+
 // See Mozilla bug 163260.
 // This file can only be included in an Objective-C context.
 
 static void nsObjCExceptionLog(NSException* aException)
 {
   NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]",
         [aException name], [aException reason]);
 
@@ -183,60 +189,60 @@ NS_OBJC_TRY_EXPR(_e, 0)
 NS_OBJC_TRY(_e, )
 
 // To reduce code size the abort versions do not reuse above macros. This allows
 // catch blocks to only contain one call.
 
 #define NS_OBJC_TRY_ABORT(_e)                      \
 @try { _e; }                                       \
 @catch(NSException *_exn) {                        \
-  nsObjCExceptionLogAbort(_exn);                   \
+  nsObjCExceptionLog(_exn);                        \
 }
 
 #define NS_OBJC_TRY_EXPR_ABORT(_e)                 \
 ({                                                 \
    typeof(_e) _tmp;                                \
    @try { _tmp = (_e); }                           \
    @catch(NSException *_exn) {                     \
-     nsObjCExceptionLogAbort(_exn);                \
+     nsObjCExceptionLog(_exn);                     \
    }                                               \
    _tmp;                                           \
 })
 
-// For wrapping blocks of Obj-C calls. Terminates app after logging.
+// For wrapping blocks of Obj-C calls. Does not actually terminate.
 #define NS_OBJC_BEGIN_TRY_ABORT_BLOCK @try {
-#define NS_OBJC_END_TRY_ABORT_BLOCK   } @catch(NSException *_exn) {            \
-                                        nsObjCExceptionLogAbort(_exn);         \
+#define NS_OBJC_END_TRY_ABORT_BLOCK   } @catch(NSException *_exn) {             \
+                                        nsObjCExceptionLog(_exn);               \
                                       }
 
 // Same as above ABORT_BLOCK but returns a value after the try/catch block to
 // suppress compiler warnings. This allows us to avoid having to refactor code
 // to get scoping right when wrapping an entire method.
 
 #define NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL @try {
-#define NS_OBJC_END_TRY_ABORT_BLOCK_NIL   } @catch(NSException *_exn) {        \
-                                            nsObjCExceptionLogAbort(_exn);     \
-                                          }                                    \
+#define NS_OBJC_END_TRY_ABORT_BLOCK_NIL   } @catch(NSException *_exn) {         \
+                                            nsObjCExceptionLog(_exn);           \
+                                          }                                     \
                                           return nil;
 
 #define NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSNULL @try {
-#define NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL   } @catch(NSException *_exn) {     \
-                                               nsObjCExceptionLogAbort(_exn);  \
-                                             }                                 \
+#define NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL   } @catch(NSException *_exn) {      \
+                                               nsObjCExceptionLog(_exn);        \
+                                             }                                  \
                                              return nsnull;
 
 #define NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT @try {
-#define NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT   } @catch(NSException *_exn) {   \
-                                                 nsObjCExceptionLogAbort(_exn);\
-                                               }                               \
+#define NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT   } @catch(NSException *_exn) {    \
+                                                 nsObjCExceptionLog(_exn);      \
+                                               }                                \
                                                return NS_ERROR_FAILURE;
 
 #define NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN    @try {
 #define NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(_rv) } @catch(NSException *_exn) {   \
-                                                  nsObjCExceptionLogAbort(_exn);\
+                                                  nsObjCExceptionLog(_exn);\
                                                 }                               \
                                                 return _rv;
 
 #define NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK @try {
 #define NS_OBJC_END_TRY_LOGONLY_BLOCK   } @catch(NSException *_exn) {           \
                                           nsObjCExceptionLog(_exn);             \
                                         }