Bug 961488: fix crash in mozJSComponentLoader::Import on 32-bits powerpc/sparc unix-but-non-mac oses. r=bz,glandium f=stevesn,spectre
authorLandry Breuil <landry@openbsd.org>
Tue, 27 May 2014 07:56:54 +0200
changeset 185018 d16fcad6aa6056926a5c1f22f17f1ffd2d994b09
parent 185017 3e8879b65201bf566c601420a32377954e6db79d
child 185019 8b8bbe7aa1cc72a399b98419766fce3bb2ad48e1
push id43999
push userlandry@openbsd.org
push dateTue, 27 May 2014 09:51:58 +0000
treeherdermozilla-inbound@d16fcad6aa60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, glandium
bugs961488
milestone32.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 961488: fix crash in mozJSComponentLoader::Import on 32-bits powerpc/sparc unix-but-non-mac oses. r=bz,glandium f=stevesn,spectre
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
@@ -1339,19 +1339,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    :