Skip to content
Snippets Groups Projects
Commit 2139bb5e authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix all the "Not in request" assertions with debug JS

This still appears to not fix valgrind on FreeBSD. :(
The background thread thing is interesting though because there's
an implication that the thread ID matters to GC in the assertion,
and we were very sloppy about requests in there.
parent b580def0
Branches
Tags
No related merge requests found
Pipeline #8060 failed
...@@ -302,6 +302,7 @@ js_load(JSContext *cx, uintN argc, jsval *arglist) ...@@ -302,6 +302,7 @@ js_load(JSContext *cx, uintN argc, jsval *arglist)
bg->cb.bg = TRUE; bg->cb.bg = TRUE;
// Get the js.internal private data since it's the parents js_callback_t... // Get the js.internal private data since it's the parents js_callback_t...
JS_RESUMEREQUEST(cx, rc);
if ((JS_GetProperty(cx, scope, "js", &val) && !JSVAL_NULL_OR_VOID(val)) if ((JS_GetProperty(cx, scope, "js", &val) && !JSVAL_NULL_OR_VOID(val))
|| (JS_GetProperty(cx, obj, "js", &val) && !JSVAL_NULL_OR_VOID(val))) { || (JS_GetProperty(cx, obj, "js", &val) && !JSVAL_NULL_OR_VOID(val))) {
js_internal = JSVAL_TO_OBJECT(val); js_internal = JSVAL_TO_OBJECT(val);
...@@ -315,6 +316,7 @@ js_load(JSContext *cx, uintN argc, jsval *arglist) ...@@ -315,6 +316,7 @@ js_load(JSContext *cx, uintN argc, jsval *arglist)
else { else {
lprintf(LOG_ERR, "!ERROR unable to locate global js object"); lprintf(LOG_ERR, "!ERROR unable to locate global js object");
} }
rc = JS_SUSPENDREQUEST(cx);
if ((bg->runtime = jsrt_GetNew(JAVASCRIPT_MAX_BYTES, 1000, __FILE__, __LINE__)) == NULL) { if ((bg->runtime = jsrt_GetNew(JAVASCRIPT_MAX_BYTES, 1000, __FILE__, __LINE__)) == NULL) {
free(bg); free(bg);
...@@ -402,18 +404,53 @@ js_load(JSContext *cx, uintN argc, jsval *arglist) ...@@ -402,18 +404,53 @@ js_load(JSContext *cx, uintN argc, jsval *arglist)
} }
// These js_Create*Object() functions use GetContextPrivate() for the sbbs_t. // These js_Create*Object() functions use GetContextPrivate() for the sbbs_t.
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
JS_SetContextPrivate(bg->cx, JS_GetContextPrivate(bg->parent_cx)); JS_SetContextPrivate(bg->cx, JS_GetContextPrivate(bg->parent_cx));
if (JS_HasProperty(cx, obj, "bbs", &success) && success) brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
if (JS_HasProperty(cx, obj, "bbs", &success) && success) {
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
js_CreateBbsObject(bg->cx, bg->obj); js_CreateBbsObject(bg->cx, bg->obj);
if (JS_HasProperty(cx, obj, "console", &success) && success) brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
}
if (JS_HasProperty(cx, obj, "console", &success) && success) {
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
js_CreateConsoleObject(bg->cx, bg->obj); js_CreateConsoleObject(bg->cx, bg->obj);
if (JS_HasProperty(cx, obj, "stdin", &success) && success) brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
}
if (JS_HasProperty(cx, obj, "stdin", &success) && success) {
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
js_CreateFileObject(bg->cx, bg->obj, "stdin", STDIN_FILENO, "r"); js_CreateFileObject(bg->cx, bg->obj, "stdin", STDIN_FILENO, "r");
if (JS_HasProperty(cx, obj, "stdout", &success) && success) brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
}
if (JS_HasProperty(cx, obj, "stdout", &success) && success) {
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
js_CreateFileObject(bg->cx, bg->obj, "stdout", STDOUT_FILENO, "w"); js_CreateFileObject(bg->cx, bg->obj, "stdout", STDOUT_FILENO, "w");
if (JS_HasProperty(cx, obj, "stderr", &success) && success) brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
}
if (JS_HasProperty(cx, obj, "stderr", &success) && success) {
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
js_CreateFileObject(bg->cx, bg->obj, "stderr", STDERR_FILENO, "w"); js_CreateFileObject(bg->cx, bg->obj, "stderr", STDERR_FILENO, "w");
brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
}
rc = JS_SUSPENDREQUEST(cx);
JS_RESUMEREQUEST(bg->cx, brc);
JS_SetContextPrivate(bg->cx, bg); JS_SetContextPrivate(bg->cx, bg);
brc = JS_SUSPENDREQUEST(bg->cx);
JS_RESUMEREQUEST(cx, rc);
exec_cx = bg->cx; exec_cx = bg->cx;
exec_obj = bg->obj; exec_obj = bg->obj;
......
...@@ -158,8 +158,10 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp) ...@@ -158,8 +158,10 @@ static JSBool js_user_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
rc = JS_SUSPENDREQUEST(cx); rc = JS_SUSPENDREQUEST(cx);
js_getuserdat(scfg, p); js_getuserdat(scfg, p);
JS_RESUMEREQUEST(cx, rc);
JS_IdToValue(cx, id, &idval); JS_IdToValue(cx, id, &idval);
tiny = JSVAL_TO_INT(idval); tiny = JSVAL_TO_INT(idval);
rc = JS_SUSPENDREQUEST(cx);
switch (tiny) { switch (tiny) {
case USER_PROP_NUMBER: case USER_PROP_NUMBER:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment