Backed out changeset 13c976344b69 (bug 1557254) for causing bug 1558836 and bug 1558852 a=backout
authorAndreea Pavel <apavel@mozilla.com>
Wed, 12 Jun 2019 20:27:00 +0300
changeset 478488 3ab360f56144d5c93dbb7ca8e1adab90f2a7f29b
parent 478409 e7e81a32c2ab11f089f9c53eab71da94902f8e6d
child 478507 32de23ddd8e2dd5efceec60f658bda00555e3852
push id113422
push useraciure@mozilla.com
push dateWed, 12 Jun 2019 21:46:30 +0000
treeherdermozilla-inbound@ff20c8ec7464 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1557254, 1558836, 1558852
milestone69.0a1
backs out13c976344b699aab96156c7dedd8c41413c8ad69
first release with
nightly linux32
3ab360f56144 / 69.0a1 / 20190612172942 / files
nightly linux64
3ab360f56144 / 69.0a1 / 20190612172942 / files
nightly mac
3ab360f56144 / 69.0a1 / 20190612172942 / files
nightly win32
3ab360f56144 / 69.0a1 / 20190612172942 / files
nightly win64
3ab360f56144 / 69.0a1 / 20190612172942 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 13c976344b69 (bug 1557254) for causing bug 1558836 and bug 1558852 a=backout
js/xpconnect/src/XPCConvert.cpp
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -403,48 +403,41 @@ bool XPCConvert::NativeData2JS(JSContext
       NS_ERROR("bad type");
       return false;
   }
   return true;
 }
 
 /***************************************************************************/
 
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+#ifdef DEBUG
 static bool CheckChar16InCharRange(char16_t c) {
   if (ILLEGAL_RANGE(c)) {
     /* U+0080/U+0100 - U+FFFF data lost. */
-    MOZ_CRASH("char16_t out of char range; high bits of data lost");
+    static const size_t MSG_BUF_SIZE = 64;
+    char msg[MSG_BUF_SIZE];
+    snprintf(msg, MSG_BUF_SIZE,
+             "char16_t out of char range; high bits of data lost: 0x%x",
+             int(c));
+    NS_WARNING(msg);
     return false;
   }
 
   return true;
 }
 
-#  ifdef STRICT_CHECK_OF_UNICODE
 template <typename CharT>
 static void CheckCharsInCharRange(const CharT* chars, size_t len) {
-  if (!IsASCII(MakeSpan(chars, len))) {
-    MOZ_CRASH("char16_t out of char range; high bits of data lost");
+  for (size_t i = 0; i < len; i++) {
+    if (!CheckChar16InCharRange(chars[i])) {
+      break;
+    }
   }
 }
-
-static void CheckCharsInCharRange(const unsigned char* chars, size_t len) {
-  return CheckCharsInCharRange(reinterpret_cast<const char*>(chars), len);
-}
-#  else   // STRICT_CHECK_OF_UNICODE
-static void CheckCharsInCharRange(const char* chars, size_t len) = delete;
-
-static void CheckCharsInCharRange(const char16_t* chars, size_t len) {
-  if (!IsUTF16Latin1(MakeSpan(chars, len))) {
-    MOZ_CRASH("char16_t out of char range; high bits of data lost");
-  }
-}
-#  endif  // STRICT_CHECK_OF_UNICODE
-#endif    // MOZ_DIAGNOSTIC_ASSERT_ENABLED
+#endif
 
 template <typename T>
 bool ConvertToPrimitive(JSContext* cx, HandleValue v, T* retval) {
   return ValueToPrimitive<T, eDefault>(cx, v, retval);
 }
 
 // static
 bool XPCConvert::JSData2Native(JSContext* cx, void* d, HandleValue s,
@@ -493,17 +486,17 @@ bool XPCConvert::JSData2Native(JSContext
       char16_t ch;
       if (JS_GetStringLength(str) == 0) {
         ch = 0;
       } else {
         if (!JS_GetStringCharAt(cx, str, 0, &ch)) {
           return false;
         }
       }
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+#ifdef DEBUG
       CheckChar16InCharRange(ch);
 #endif
       *((char*)d) = char(ch);
       break;
     }
     case nsXPTType::T_WCHAR: {
       JSString* str;
       if (!(str = ToString(cx, s))) {
@@ -602,37 +595,35 @@ bool XPCConvert::JSData2Native(JSContext
         return true;
       }
 
       JSString* str = ToString(cx, s);
       if (!str) {
         return false;
       }
 
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+#ifdef DEBUG
       if (JS_StringHasLatin1Chars(str)) {
-#  ifdef STRICT_CHECK_OF_UNICODE
         size_t len;
         AutoCheckCannotGC nogc;
         const Latin1Char* chars =
             JS_GetLatin1StringCharsAndLength(cx, nogc, str, &len);
         if (chars) {
           CheckCharsInCharRange(chars, len);
         }
-#  endif  // STRICT_CHECK_OF_UNICODE
       } else {
         size_t len;
         AutoCheckCannotGC nogc;
         const char16_t* chars =
             JS_GetTwoByteStringCharsAndLength(cx, nogc, str, &len);
         if (chars) {
           CheckCharsInCharRange(chars, len);
         }
       }
-#endif  // MOZ_DIAGNOSTIC_ASSERT_ENABLED
+#endif  // DEBUG
 
       size_t length = JS_GetStringEncodingLength(cx, str);
       if (length == size_t(-1)) {
         return false;
       }
       if (sizeis) {
         if (length > arrlen) {
           if (pErr) {
@@ -737,38 +728,16 @@ bool XPCConvert::JSData2Native(JSContext
       }
 
       // The JS val is neither null nor void...
       JSString* str = ToString(cx, s);
       if (!str) {
         return false;
       }
 
-#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
-      if (JS_StringHasLatin1Chars(str)) {
-#  ifdef STRICT_CHECK_OF_UNICODE
-        size_t len;
-        AutoCheckCannotGC nogc;
-        const Latin1Char* chars =
-            JS_GetLatin1StringCharsAndLength(cx, nogc, str, &len);
-        if (chars) {
-          CheckCharsInCharRange(chars, len);
-        }
-#  endif  // STRICT_CHECK_OF_UNICODE
-      } else {
-        size_t len;
-        AutoCheckCannotGC nogc;
-        const char16_t* chars =
-            JS_GetTwoByteStringCharsAndLength(cx, nogc, str, &len);
-        if (chars) {
-          CheckCharsInCharRange(chars, len);
-        }
-      }
-#endif  // MOZ_DIAGNOSTIC_ASSERT_ENABLED
-
       size_t length = JS_GetStringEncodingLength(cx, str);
       if (length == size_t(-1)) {
         return false;
       }
 
       if (!length) {
         rs->Truncate();
         return true;