[couchdb/f15] Hopefully, this will fix segfaults with new js-1.8.5

Peter Lemenkov peter at fedoraproject.org
Mon May 30 13:58:39 UTC 2011


commit eff7d53cf764b6bf5f6bd2d8aa4773791adcff9f
Author: Peter Lemenkov <lemenkov at gmail.com>
Date:   Mon May 30 17:21:15 2011 +0400

    Hopefully, this will fix segfaults with new js-1.8.5
    
    Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>

 couchdb-0014-Fix-for-js-1.8.5.patch |   92 +++++++++++++++++++++++++++++++++++
 couchdb.spec                        |    9 +++-
 2 files changed, 100 insertions(+), 1 deletions(-)
---
diff --git a/couchdb-0014-Fix-for-js-1.8.5.patch b/couchdb-0014-Fix-for-js-1.8.5.patch
new file mode 100644
index 0000000..695bf5f
--- /dev/null
+++ b/couchdb-0014-Fix-for-js-1.8.5.patch
@@ -0,0 +1,92 @@
+From 7e6bc002508b34d21a025865f65a27c8f5969c43 Mon Sep 17 00:00:00 2001
+From: Martin Stransky <stransky at redhat.com>
+Date: Mon, 30 May 2011 21:12:59 +0400
+Subject: [PATCH 14/14] Fix for js-1.8.5
+
+---
+ src/couchdb/priv/couch_js/main.c |   29 +++++++++++++++++------------
+ 1 files changed, 17 insertions(+), 12 deletions(-)
+
+diff --git a/src/couchdb/priv/couch_js/main.c b/src/couchdb/priv/couch_js/main.c
+index 243e971..bcd8096 100644
+--- a/src/couchdb/priv/couch_js/main.c
++++ b/src/couchdb/priv/couch_js/main.c
+@@ -10,11 +10,13 @@
+ // License for the specific language governing permissions and limitations under
+ // the License.
+ 
++#include <assert.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <jsapi.h>
+ #include "config.h"
++
+ #include "utf8.h"
+ #include "http.h"
+ 
+@@ -46,6 +48,9 @@ static JSClass global_class = {
+     JSCLASS_NO_OPTIONAL_MEMBERS
+ };
+ 
++static void
++printerror(JSContext *cx, const char *mesg, JSErrorReport *report);
++
+ static JSBool
+ evalcx(JSContext *cx, uintN argc, jsval *vp)
+ {
+@@ -63,7 +68,6 @@ evalcx(JSContext *cx, uintN argc, jsval *vp)
+         return JS_FALSE;
+     }
+ 
+-
+     subcx = JS_NewContext(JS_GetRuntime(cx), 8L * 1024L);
+     if(!subcx)
+     {
+@@ -71,20 +75,17 @@ evalcx(JSContext *cx, uintN argc, jsval *vp)
+         return JS_FALSE;
+     }
+ 
+-    JSObject *global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
+-    if (!global) return 1;
+-    JS_SetGlobalObject(subcx, global);
+-
+     SETUP_REQUEST(subcx);
+ 
+-    src = JS_GetStringCharsZ(cx, str);
+-    srclen = JS_GetStringLength(str);
+-
+     if(!sandbox)
+     {
+-        sandbox = JS_NewObject(subcx, NULL, NULL, NULL);
+-        if(!sandbox || !JS_InitStandardClasses(subcx, global)) goto done;
++        sandbox = JS_NewCompartmentAndGlobalObject(subcx, &global_class, NULL);
++        if(!sandbox || !JS_InitStandardClasses(subcx, sandbox)) goto done;
+     }
++    JS_SetGlobalObject(subcx, sandbox);
++
++    src = JS_GetStringCharsZ(subcx, str);
++    srclen = JS_GetStringLength(str);
+ 
+     if(srclen == 0)
+     {
+@@ -92,9 +93,13 @@ evalcx(JSContext *cx, uintN argc, jsval *vp)
+     }
+     else
+     {
+-        jsval rval; 
+-        JS_EvaluateUCScript(subcx, sandbox, src, srclen, NULL, 0, &rval);
+-        JS_SET_RVAL(cx, vp, rval);
++        JSObject *script = JS_CompileUCScript(subcx, sandbox, src, srclen, NULL, 0);
++        jsval rval;
++        if(script)
++        {
++            JS_ExecuteScript(subcx, sandbox, script, &rval);
++            JS_SET_RVAL(cx, vp, rval);
++        }
+     }
+     
+     ret = JS_TRUE;
+-- 
+1.7.5.2
+
diff --git a/couchdb.spec b/couchdb.spec
index f75e036..27a75be 100644
--- a/couchdb.spec
+++ b/couchdb.spec
@@ -4,7 +4,7 @@
 
 Name:           couchdb
 Version:        1.0.2
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        A document database server, accessible via a RESTful JSON API
 
 Group:          Applications/Databases
@@ -25,6 +25,7 @@ Patch10:	couchdb-0010-Relax-curl-dependency-to-7.15-for-RHEL5.patch
 Patch11:	couchdb-0011-Added-Spidermonkey-1.8.5-patch.patch
 Patch12:	couchdb-0012-Replicator-fix-error-when-restarting-replications-in.patch
 Patch13:	couchdb-0013-Fix-for-ibrowse-2.2.0.patch
+Patch14:	couchdb-0014-Fix-for-js-1.8.5.patch
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
@@ -94,6 +95,9 @@ JavaScript acting as the default view definition language.
 %if 0%{?fc15}%{?fc16}
 %patch13 -p1 -b .ibrowse_2_2_0
 %endif
+%if 0%{?fc15}%{?fc16}
+%patch14 -p1 -b .to_new_js_again
+%endif
 
 # Remove bundled libraries
 rm -rf src/erlang-oauth
@@ -168,6 +172,9 @@ fi
 
 
 %changelog
+* Mon May 30 2011 Peter Lemenkov <lemenkov at gmail.com> - 1.0.2-6
+- Patched patch for new js-1.8.5
+
 * Fri May 20 2011 Peter Lemenkov <lemenkov at gmail.com> - 1.0.2-5
 - Fixed issue with ibrowse-2.2.0
 


More information about the scm-commits mailing list