Bug 961488: fix crash in mozJSComponentLoader::Import on 32-bits powerpc/sparc unix-but-non-mac oses. r=bz,glandium f=stevesn,spectre a=lsblakk
authorLandry Breuil <landry@openbsd.org>
Tue, 27 May 2014 07:56:54 +0200
changeset 199337 8852081d200428b55b96360fedfe6090308eceb2
parent 199336 72fc3c8e822088e2b60c1087dc87d1865a699aa4
child 199338 ad2258fa2e1a44fb7f9a09ed829508225cef8551
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, glandium, lsblakk
bugs961488
milestone31.0a2
Bug 961488: fix crash in mozJSComponentLoader::Import on 32-bits powerpc/sparc unix-but-non-mac oses. r=bz,glandium f=stevesn,spectre a=lsblakk
js/xpconnect/src/XPCWrappedJSClass.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_linux.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_netbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_netbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_openbsd.cpp
xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_solaris.cpp
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -1352,19 +1352,31 @@ pre_call_clean_up:
 
         if (type_tag == nsXPTType::T_INTERFACE) {
             if (NS_FAILED(GetInterfaceInfo()->
                           GetIIDForParamNoAlloc(methodIndex, &param,
                                                 &param_iid)))
                 break;
         }
 
-        if (!XPCConvert::JSData2Native(&pv->val, val, type,
-                                       !param.IsDipper(), &param_iid, nullptr))
-            break;
+// see bug #961488
+#if (defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(_AIX)) && \
+    ((defined(__sparc) && !defined(__sparcv9) && !defined(__sparcv9__)) || \
+    (defined(__powerpc__) && !defined (__powerpc64__)))
+        if (type_tag == nsXPTType::T_JSVAL) {
+            if (!XPCConvert::JSData2Native(*(void**)(&pv->val), val, type,
+                                           !param.IsDipper(), &param_iid, nullptr))
+                break;
+        } else
+#endif
+        {
+            if (!XPCConvert::JSData2Native(&pv->val, val, type,
+                                           !param.IsDipper(), &param_iid, nullptr))
+                break;
+        }
     }
 
     // if any params were dependent, then we must iterate again to convert them.
     if (foundDependentParam && i == paramCount) {
         for (i = 0; i < paramCount; i++) {
             const nsXPTParamInfo& param = info->params[i];
             if (!param.IsOut())
                 continue;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_linux.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_linux.cpp
@@ -40,18 +40,22 @@ invoke_copy_to_stack(uint32_t* d,
     uint32_t gpr = 1; // skip one GP reg for 'that'
 #ifndef __NO_FPRS__
     uint32_t fpr = 0;
 #endif
     uint32_t tempu32;
     uint64_t tempu64;
     
     for(uint32_t i = 0; i < paramCount; i++, s++) {
-        if(s->IsPtrData())
-            tempu32 = (uint32_t) s->ptr;
+        if(s->IsPtrData()) {
+            if(s->type == nsXPTType::T_JSVAL)
+                tempu32 = (uint32_t) &s->ptr;
+            else
+                tempu32 = (uint32_t) s->ptr;
+        }
         else {
             switch(s->type) {
             case nsXPTType::T_FLOAT:                                  break;
             case nsXPTType::T_DOUBLE:                                 break;
             case nsXPTType::T_I8:     tempu32 = s->val.i8;            break;
             case nsXPTType::T_I16:    tempu32 = s->val.i16;           break;
             case nsXPTType::T_I32:    tempu32 = s->val.i32;           break;
             case nsXPTType::T_I64:    tempu64 = s->val.i64;           break;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_netbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_netbsd.cpp
@@ -36,19 +36,22 @@ invoke_copy_to_stack(uint32_t* d,
                      double* fpregs)
 {
     uint32_t gpr = 1; // skip one GP reg for 'that'
     uint32_t fpr = 0;
     uint32_t tempu32;
     uint64_t tempu64;
     
     for(uint32_t i = 0; i < paramCount; i++, s++) {
-        if(s->IsPtrData())
-            tempu32 = (uint32_t) s->ptr;
-        else {
+        if(s->IsPtrData()) {
+            if(s->type == nsXPTType::T_JSVAL)
+               tempu32 = (uint32_t) &(s->ptr);
+            else
+               tempu32 = (uint32_t) s->ptr;
+        } else {
             switch(s->type) {
             case nsXPTType::T_FLOAT:                                  break;
             case nsXPTType::T_DOUBLE:                                 break;
             case nsXPTType::T_I8:     tempu32 = s->val.i8;            break;
             case nsXPTType::T_I16:    tempu32 = s->val.i16;           break;
             case nsXPTType::T_I32:    tempu32 = s->val.i32;           break;
             case nsXPTType::T_I64:    tempu64 = s->val.i64;           break;
             case nsXPTType::T_U8:     tempu32 = s->val.u8;            break;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc_openbsd.cpp
@@ -36,19 +36,22 @@ invoke_copy_to_stack(uint32_t* d,
                      double* fpregs)
 {
     uint32_t gpr = 1; // skip one GP reg for 'that'
     uint32_t fpr = 0;
     uint32_t tempu32;
     uint64_t tempu64;
     
     for(uint32_t i = 0; i < paramCount; i++, s++) {
-        if(s->IsPtrData())
-            tempu32 = (uint32_t) s->ptr;
-        else {
+        if(s->IsPtrData()) {
+            if(s->type == nsXPTType::T_JSVAL)
+               tempu32 = (uint32_t) &(s->ptr);
+            else
+               tempu32 = (uint32_t) s->ptr;
+        } else {
             switch(s->type) {
             case nsXPTType::T_FLOAT:                                  break;
             case nsXPTType::T_DOUBLE:                                 break;
             case nsXPTType::T_I8:     tempu32 = s->val.i8;            break;
             case nsXPTType::T_I16:    tempu32 = s->val.i16;           break;
             case nsXPTType::T_I32:    tempu32 = s->val.i32;           break;
             case nsXPTType::T_I64:    tempu64 = s->val.i64;           break;
             case nsXPTType::T_U8:     tempu32 = s->val.u8;            break;
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_netbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_netbsd.cpp
@@ -87,17 +87,24 @@ invoke_copy_to_stack(uint32_t* d, uint32
     } DU;               // have to move 64 bit entities as 32 bit halves since
                         // stack slots are not guaranteed 16 byte aligned
 
     for(uint32_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
     {
 	if (regCount < 5) regCount++;
         if(l_s->IsPtrData())
         {
-            *((void**)l_d) = l_s->ptr;
+            if(l_s->type == nsXPTType::T_JSVAL)
+            {
+              // On SPARC, we need to pass a pointer to HandleValue
+              *((void**)l_d) = &l_s->ptr;
+            } else
+            {
+              *((void**)l_d) = l_s->ptr;
+            }
             continue;
         }
         switch(l_s->type)
         {
         case nsXPTType::T_I8     : *((int32_t*)   l_d) = l_s->val.i8;          break;
         case nsXPTType::T_I16    : *((int32_t*)  l_d) = l_s->val.i16;         break;
         case nsXPTType::T_I32    : *((int32_t*)  l_d) = l_s->val.i32;         break;
         case nsXPTType::T_I64    : 
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_openbsd.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_openbsd.cpp
@@ -84,17 +84,24 @@ invoke_copy_to_stack(uint32_t* d, uint32
     } DU;               // have to move 64 bit entities as 32 bit halves since
                         // stack slots are not guaranteed 16 byte aligned
 
     for(uint32_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
     {
 	if (regCount < 5) regCount++;
         if(l_s->IsPtrData())
         {
-            *((void**)l_d) = l_s->ptr;
+            if(l_s->type == nsXPTType::T_JSVAL)
+            {
+              // On SPARC, we need to pass a pointer to HandleValue
+              *((void**)l_d) = &l_s->ptr;
+            } else
+            {
+              *((void**)l_d) = l_s->ptr;
+            }
             continue;
         }
         switch(l_s->type)
         {
         case nsXPTType::T_I8     : *((int32_t*)  l_d) = l_s->val.i8;          break;
         case nsXPTType::T_I16    : *((int32_t*)  l_d) = l_s->val.i16;         break;
         case nsXPTType::T_I32    : *((int32_t*)  l_d) = l_s->val.i32;         break;
         case nsXPTType::T_I64    : 
--- a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_solaris.cpp
+++ b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_sparc_solaris.cpp
@@ -87,17 +87,24 @@ invoke_copy_to_stack(uint32_t* d, uint32
     } DU;               // have to move 64 bit entities as 32 bit halves since
                         // stack slots are not guaranteed 16 byte aligned
 
     for(uint32_t i = 0; i < l_paramCount; i++, l_d++, l_s++)
     {
 	if (regCount < 5) regCount++;
         if(l_s->IsPtrData())
         {
-            *((void**)l_d) = l_s->ptr;
+            if(l_s->type == nsXPTType::T_JSVAL)
+            {
+              // On SPARC, we need to pass a pointer to HandleValue
+              *((void**)l_d) = &l_s->ptr;
+            } else
+            {
+              *((void**)l_d) = l_s->ptr;
+            }
             continue;
         }
         switch(l_s->type)
         {
         case nsXPTType::T_I8     : *((int32_t*)   l_d) = l_s->val.i8;          break;
         case nsXPTType::T_I16    : *((int32_t*)  l_d) = l_s->val.i16;         break;
         case nsXPTType::T_I32    : *((int32_t*)  l_d) = l_s->val.i32;         break;
         case nsXPTType::T_I64    :