Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 289427 Details for
Bug 366729
dev-db/couchdb / dev-lang/spidermonkey-1.8.2.x / net-libs/xulrunner-2.0 - couchjs segfaults
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
couchdb 1.1.0 patch for spidermonkey 1.8.5
js185.patch (text/plain), 13.03 KB, created by
Tilo Prütz
on 2011-10-10 06:03:46 UTC
(
hide
)
Description:
couchdb 1.1.0 patch for spidermonkey 1.8.5
Filename:
MIME Type:
Creator:
Tilo Prütz
Created:
2011-10-10 06:03:46 UTC
Size:
13.03 KB
patch
obsolete
>--- configure.orig 2011-10-05 14:32:55.000000000 +0200 >+++ configure 2011-10-05 14:35:57.000000000 +0200 >@@ -11372,13 +11372,13 @@ > fi > > >-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JS_NewContext in -lmozjs" >&5 >-$as_echo_n "checking for JS_NewContext in -lmozjs... " >&6; } >+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JS_NewContext in -lmozjs185" >&5 >+$as_echo_n "checking for JS_NewContext in -lmozjs185... " >&6; } > if test "${ac_cv_lib_mozjs_JS_NewContext+set}" = set; then : > $as_echo_n "(cached) " >&6 > else > ac_check_lib_save_LIBS=$LIBS >-LIBS="-lmozjs $LIBS" >+LIBS="-lmozjs185 $LIBS" > cat confdefs.h - <<_ACEOF >conftest.$ac_ext > /* end confdefs.h. */ > >@@ -11409,7 +11409,7 @@ > { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mozjs_JS_NewContext" >&5 > $as_echo "$ac_cv_lib_mozjs_JS_NewContext" >&6; } > if test "x$ac_cv_lib_mozjs_JS_NewContext" = x""yes; then : >- JS_LIB_BASE=mozjs >+ JS_LIB_BASE=mozjs185 > else > > { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JS_NewContext in -ljs" >&5 >--- src/couchdb/priv/couch_js/http.c.to_new_js 2010-06-15 18:27:22.000000000 +0200 >+++ src/couchdb/priv/couch_js/http.c 2011-05-03 16:09:18.347552983 +0200 >@@ -49,12 +49,25 @@ go(JSContext* cx, JSObject* obj, HTTPDat > static JSString* > str_from_binary(JSContext* cx, char* data, size_t length); > >+JSClass CouchHTTPClass; >+ > static JSBool >-constructor(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) >+constructor(JSContext* cx, uintN argc, jsval* vp) > { > HTTPData* http = NULL; > JSBool ret = JS_FALSE; >+ jsval* argv = JS_ARGV(cx, vp); >+ JSObject *obj = NULL; >+ //if (JS_IsConstructing(cx, vp)) { >+ obj = JS_NewObject(cx, &CouchHTTPClass, NULL, NULL); >+ if (!obj) >+ return JS_FALSE; >+ //} else { >+ // obj = JS_THIS_OBJECT(cx, vp); >+ //} >+ //printf("con %x\n", obj); > >+ JSBool *con = JS_IsConstructing(cx, vp); > http = (HTTPData*) malloc(sizeof(HTTPData)); > if(!http) > { >@@ -67,6 +80,7 @@ constructor(JSContext* cx, JSObject* obj > http->req_headers = NULL; > http->last_status = -1; > >+ JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj)); > if(!JS_SetPrivate(cx, obj, http)) > { > JS_ReportError(cx, "Failed to set private CouchHTTP data."); >@@ -90,6 +104,7 @@ destructor(JSContext* cx, JSObject* obj) > if(!http) > { > fprintf(stderr, "Unable to destroy invalid CouchHTTP instance.\n"); >+ //printf("Unable to destroy invalid CouchHTTP instance.\n"); > } > else > { >@@ -100,12 +115,15 @@ destructor(JSContext* cx, JSObject* obj) > } > > static JSBool >-open(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) >-{ >- HTTPData* http = (HTTPData*) JS_GetPrivate(cx, obj); >+open(JSContext* cx, uintN argc, jsval* vp) >+{ >+ JSObject *obj = JS_THIS_OBJECT(cx, vp); >+ //printf("open %x\n", obj); >+ HTTPData* http = (HTTPData*) JS_GetPrivate(cx, JS_THIS_OBJECT(cx, vp)); > char* method = NULL; > char* url = NULL; > JSBool ret = JS_FALSE; >+ jsval* argv = JS_ARGV(cx, vp); > int methid; > > if(!http) >@@ -182,14 +200,16 @@ done: > } > > static JSBool >-setheader(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) >+setheader(JSContext* cx, uintN argc, jsval* vp) > { >- HTTPData* http = (HTTPData*) JS_GetPrivate(cx, obj); >+ //printf("setheader %x\n", JS_THIS_OBJECT(cx, vp)); >+ HTTPData* http = (HTTPData*) JS_GetPrivate(cx, JS_THIS_OBJECT(cx, vp)); > char* keystr = NULL; > char* valstr = NULL; > char* hdrbuf = NULL; > size_t hdrlen = -1; > JSBool ret = JS_FALSE; >+ jsval* argv = JS_ARGV(cx, vp); > > if(!http) > { >@@ -245,12 +265,14 @@ done: > } > > static JSBool >-sendreq(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) >+sendreq(JSContext* cx, uintN argc, jsval* vp) > { >- HTTPData* http = (HTTPData*) JS_GetPrivate(cx, obj); >+ HTTPData* http = (HTTPData*) JS_GetPrivate(cx, JS_THIS_OBJECT(cx, vp)); >+ //printf("sendreq %x\n", JS_THIS_OBJECT(cx, vp)); > char* body = NULL; > size_t bodylen = 0; > JSBool ret = JS_FALSE; >+ jsval* argv = JS_ARGV(cx, vp); > > if(!http) > { >@@ -268,7 +290,7 @@ sendreq(JSContext* cx, JSObject* obj, ui > } > } > >- ret = go(cx, obj, http, body, bodylen); >+ ret = go(cx, JS_THIS_OBJECT(cx, argv), http, body, bodylen); > > done: > if(body) free(body); >@@ -276,7 +298,7 @@ done: > } > > static JSBool >-status(JSContext* cx, JSObject* obj, jsval idval, jsval* vp) >+status(JSContext* cx, JSObject* obj, jsid idval, jsval* vp) > { > HTTPData* http = (HTTPData*) JS_GetPrivate(cx, obj); > >@@ -286,16 +308,8 @@ status(JSContext* cx, JSObject* obj, jsv > return JS_FALSE; > } > >- if(INT_FITS_IN_JSVAL(http->last_status)) >- { >- *vp = INT_TO_JSVAL(http->last_status); >- return JS_TRUE; >- } >- else >- { >- JS_ReportError(cx, "INTERNAL: Invalid last_status"); >- return JS_FALSE; >- } >+ *vp = INT_TO_JSVAL(http->last_status); >+ return JS_TRUE; > } > > JSClass CouchHTTPClass = { >@@ -306,7 +320,7 @@ JSClass CouchHTTPClass = { > JS_PropertyStub, > JS_PropertyStub, > JS_PropertyStub, >- JS_PropertyStub, >+ JS_StrictPropertyStub, > JS_EnumerateStub, > JS_ResolveStub, > JS_ConvertStub, >@@ -320,10 +334,10 @@ JSPropertySpec CouchHTTPProperties[] = { > }; > > JSFunctionSpec CouchHTTPFunctions[] = { >- {"_open", open, 3, 0, 0}, >- {"_setRequestHeader", setheader, 2, 0, 0}, >- {"_send", sendreq, 1, 0, 0}, >- {0, 0, 0, 0, 0} >+ {"_open", open, 3, 0}, >+ {"_setRequestHeader", setheader, 2, 0}, >+ {"_send", sendreq, 1, 0}, >+ {0, 0, 0, 0} > }; > > JSObject* >--- src/couchdb/priv/couch_js/main.c.to_new_js 2009-11-27 23:43:59.000000000 +0100 >+++ src/couchdb/priv/couch_js/main.c 2011-05-03 16:15:56.825571272 +0200 >@@ -15,7 +15,6 @@ > #include <string.h> > #include <jsapi.h> > #include "config.h" >- > #include "utf8.h" > #include "http.h" > >@@ -33,8 +32,22 @@ int gExitCode = 0; > #define FINISH_REQUEST(cx) > #endif > >+static JSClass global_class = { >+ "GlobalClass", >+ JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_PRIVATE, >+ JS_PropertyStub, >+ JS_PropertyStub, >+ JS_PropertyStub, >+ JS_StrictPropertyStub, >+ JS_EnumerateStub, >+ JS_ResolveStub, >+ JS_ConvertStub, >+ JS_FinalizeStub, >+ JSCLASS_NO_OPTIONAL_MEMBERS >+}; >+ > static JSBool >-evalcx(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) >+evalcx(JSContext *cx, uintN argc, jsval *vp) > { > JSString *str; > JSObject *sandbox; >@@ -45,11 +58,12 @@ evalcx(JSContext *cx, JSObject *obj, uin > jsval v; > > sandbox = NULL; >- if(!JS_ConvertArguments(cx, argc, argv, "S / o", &str, &sandbox)) >+ if(!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S / o", &str, &sandbox)) > { > return JS_FALSE; > } > >+ > subcx = JS_NewContext(JS_GetRuntime(cx), 8L * 1024L); > if(!subcx) > { >@@ -57,24 +71,30 @@ evalcx(JSContext *cx, JSObject *obj, uin > return JS_FALSE; > } > >+ JSObject *global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); >+ if (!global) return 1; >+ JS_SetGlobalObject(subcx, global); >+ > SETUP_REQUEST(subcx); > >- src = JS_GetStringChars(str); >+ src = JS_GetStringCharsZ(cx, str); > srclen = JS_GetStringLength(str); > > if(!sandbox) > { > sandbox = JS_NewObject(subcx, NULL, NULL, NULL); >- if(!sandbox || !JS_InitStandardClasses(subcx, sandbox)) goto done; >+ if(!sandbox || !JS_InitStandardClasses(subcx, global)) goto done; > } > > if(srclen == 0) > { >- *rval = OBJECT_TO_JSVAL(sandbox); >+ JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(sandbox)); > } > else > { >- JS_EvaluateUCScript(subcx, sandbox, src, srclen, NULL, 0, rval); >+ jsval rval; >+ JS_EvaluateUCScript(subcx, sandbox, src, srclen, NULL, 0, &rval); >+ JS_SET_RVAL(cx, vp, rval); > } > > ret = JS_TRUE; >@@ -86,21 +106,20 @@ done: > } > > static JSBool >-gc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) >+gc(JSContext *cx, uintN argc, jsval *argv) > { > JS_GC(cx); > return JS_TRUE; > } > > static JSBool >-print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) >+print(JSContext *cx, uintN argc, jsval *argv) > { > uintN i; > char *bytes; >- > for(i = 0; i < argc; i++) > { >- bytes = enc_string(cx, argv[i], NULL); >+ bytes = enc_string(cx, JS_ARGV(cx, argv)[i], NULL); > if(!bytes) return JS_FALSE; > > fprintf(stdout, "%s%s", i ? " " : "", bytes); >@@ -113,9 +132,9 @@ print(JSContext *cx, JSObject *obj, uint > } > > static JSBool >-quit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) >+quit(JSContext *cx, uintN argc, jsval *argv) > { >- JS_ConvertArguments(cx, argc, argv, "/ i", &gExitCode); >+ JS_ConvertArguments(cx, argc, JS_ARGV(cx, argv), "/ i", &gExitCode); > return JS_FALSE; > } > >@@ -123,41 +142,23 @@ static char* > readfp(JSContext* cx, FILE* fp, size_t* buflen) > { > char* bytes = NULL; >- char* tmp = NULL; >- size_t used = 0; > size_t byteslen = 256; >- size_t readlen = 0; >+ ssize_t readlen; > > bytes = JS_malloc(cx, byteslen); >- if(bytes == NULL) return NULL; >- >- while((readlen = js_fgets(bytes+used, byteslen-used, stdin)) > 0) >- { >- used += readlen; >- >- if(bytes[used-1] == '\n') >- { >- bytes[used-1] = '\0'; >- break; >- } >- >- // Double our buffer and read more. >- byteslen *= 2; >- tmp = JS_realloc(cx, bytes, byteslen); >- if(!tmp) >- { >- JS_free(cx, bytes); >- return NULL; >- } >- bytes = tmp; >- } >- >- *buflen = used; >+ readlen = getline(&bytes, &byteslen, fp); >+ if (readlen <= 0) { >+ *buflen = 0; >+ return bytes; >+ } >+ if (bytes[readlen-1] == '\n') >+ bytes[readlen-1] = '\0'; >+ *buflen = readlen; > return bytes; > } > > static JSBool >-readline(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { >+readline(JSContext *cx, uintN argc, jsval *argv) { > jschar *chars; > JSString *str; > char* bytes; >@@ -173,7 +174,7 @@ readline(JSContext *cx, JSObject *obj, u > /* Treat the empty string specially */ > if(byteslen == 0) > { >- *rval = JS_GetEmptyStringValue(cx); >+ JS_SET_RVAL(cx, argv, JS_GetEmptyStringValue(cx)); > JS_free(cx, bytes); > return JS_TRUE; > } >@@ -191,28 +192,27 @@ readline(JSContext *cx, JSObject *obj, u > JS_free(cx, bytes); > > if(!str) return JS_FALSE; >- >- *rval = STRING_TO_JSVAL(str); >+ JS_SET_RVAL(cx, argv, STRING_TO_JSVAL(str)); > > return JS_TRUE; > } > > static JSBool >-seal(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { >+seal(JSContext *cx, uintN argc, jsval *argv) { > JSObject *target; > JSBool deep = JS_FALSE; > >- if (!JS_ConvertArguments(cx, argc, argv, "o/b", &target, &deep)) >+ if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, argv), "o/b", &target, &deep)) > return JS_FALSE; > if (!target) > return JS_TRUE; >- return JS_SealObject(cx, target, deep); >+ return JS_FreezeObject(cx, target); > } > > static void > execute_script(JSContext *cx, JSObject *obj, const char *filename) { > FILE *file; >- JSScript *script; >+ JSObject *script; > jsval result; > > if(!filename || strcmp(filename, "-") == 0) >@@ -234,7 +234,6 @@ execute_script(JSContext *cx, JSObject * > if(script) > { > JS_ExecuteScript(cx, obj, script, &result); >- JS_DestroyScript(cx, script); > } > } > >@@ -248,27 +247,13 @@ printerror(JSContext *cx, const char *me > } > > static JSFunctionSpec global_functions[] = { >- {"evalcx", evalcx, 0, 0, 0}, >- {"gc", gc, 0, 0, 0}, >- {"print", print, 0, 0, 0}, >- {"quit", quit, 0, 0, 0}, >- {"readline", readline, 0, 0, 0}, >- {"seal", seal, 0, 0, 0}, >- {0, 0, 0, 0, 0} >-}; >- >-static JSClass global_class = { >- "GlobalClass", >- JSCLASS_GLOBAL_FLAGS, >- JS_PropertyStub, >- JS_PropertyStub, >- JS_PropertyStub, >- JS_PropertyStub, >- JS_EnumerateStub, >- JS_ResolveStub, >- JS_ConvertStub, >- JS_FinalizeStub, >- JSCLASS_NO_OPTIONAL_MEMBERS >+ {"evalcx", evalcx, 0, 0}, >+ {"gc", gc, 0, 0}, >+ {"print", print, 0, 0}, >+ {"quit", quit, 0, 0}, >+ {"readline", readline, 0, 0}, >+ {"seal", seal, 0, 0}, >+ {0, 0, 0, 0} > }; > > int >@@ -291,7 +276,7 @@ main(int argc, const char * argv[]) > > SETUP_REQUEST(cx); > >- global = JS_NewObject(cx, &global_class, NULL, NULL); >+ global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); > if (!global) return 1; > if (!JS_InitStandardClasses(cx, global)) return 1; > >--- src/couchdb/priv/couch_js/utf8.c.to_new_js 2009-11-27 07:41:39.000000000 +0100 >+++ src/couchdb/priv/couch_js/utf8.c 2011-05-03 16:14:16.946819926 +0200 >@@ -129,7 +129,7 @@ enc_string(JSContext* cx, jsval arg, siz > str = JS_ValueToString(cx, arg); > if(!str) goto error; > >- src = JS_GetStringChars(str); >+ src = JS_GetStringCharsZ(cx, str); > srclen = JS_GetStringLength(str); > > if(!enc_charbuf(src, srclen, NULL, &byteslen)) goto error; >@@ -283,4 +283,4 @@ error: > > success: > return str; >-} >\ No newline at end of file >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 366729
: 289427