Bug 1129247 - Introduce MOZ_DIAGNOSTIC_ASSERT. r=Waldo
authorBobby Holley <bobbyholley@gmail.com>
Wed, 04 Feb 2015 13:13:58 -0800
changeset 227586 b5fee33019515e6d9b7bba3151961eba7ef472df
parent 227585 7a9bb617e46103a0c21e8ea29c3821339f6a46b3
child 227587 8c84373abd465b20cbaf95ed43b023dd37ab65c4
push id28235
push usercbook@mozilla.com
push dateThu, 05 Feb 2015 13:47:35 +0000
treeherdermozilla-central@58ce6051edf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1129247
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1129247 - Introduce MOZ_DIAGNOSTIC_ASSERT. r=Waldo
mfbt/Assertions.h
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -289,16 +289,23 @@ MOZ_ReportCrash(const char* aStr, const 
  *   MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(),
  *              "we already set [[PrimitiveThis]] for this Boolean object");
  *   MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(),
  *              "we already set [[PrimitiveThis]] for this String object");
  *
  * MOZ_ASSERT has no effect in non-debug builds.  It is designed to catch bugs
  * *only* during debugging, not "in the field". If you want the latter, use
  * MOZ_RELEASE_ASSERT, which applies to non-debug builds as well.
+ *
+ * MOZ_DIAGNOSTIC_ASSERT works like MOZ_RELEASE_ASSERT in Nightly/Aurora and
+ * MOZ_ASSERT in Beta/Release - use this when a condition is potentially rare
+ * enough to require real user testing to hit, but is not security-sensitive.
+ * This can cause user pain, so use it sparingly. If a MOZ_DIAGNOSTIC_ASSERT
+ * is firing, it should promptly be converted to a MOZ_ASSERT while the failure
+ * is being investigated, rather than letting users suffer.
  */
 
 /*
  * Implement MOZ_VALIDATE_ASSERT_CONDITION_TYPE, which is used to guard against
  * accidentally passing something unintended in lieu of an assertion condition.
  */
 
 #ifdef __cplusplus
@@ -373,16 +380,22 @@ struct AssertionConditionType
     (__VA_ARGS__))
 
 #ifdef DEBUG
 #  define MOZ_ASSERT(...) MOZ_RELEASE_ASSERT(__VA_ARGS__)
 #else
 #  define MOZ_ASSERT(...) do { } while (0)
 #endif /* DEBUG */
 
+#ifdef RELEASE_BUILD
+#  define MOZ_DIAGNOSTIC_ASSERT MOZ_ASSERT
+#else
+#  define MOZ_DIAGNOSTIC_ASSERT MOZ_RELEASE_ASSERT
+#endif
+
 /*
  * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is
  * true.
  *
  *   MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num));
  *
  * As with MOZ_ASSERT, MOZ_ASSERT_IF has effect only in debug builds.  It is
  * designed to catch bugs during debugging, not "in the field".