Bug 479551 - Assertion failure: (cx)->requestDepth || (cx)->thread == (cx)->runtime->gcThread, at js/src/jsapi.cpp:957 after typing EOF at js shell prompt. r=igor and mrbkap.

--HG--
extra : rebase_source : 56a0fc0823e7a9500befc65da530d86bba564a97
This commit is contained in:
Jason Orendorff 2009-02-23 17:28:46 -06:00
parent 604e62a813
commit 44263bbd33

View File

@ -216,10 +216,10 @@ GetLine(FILE *file, const char * prompt)
/*
* We set it to zero to avoid complaining about inappropriate ioctl
* for device in the case of EOF. Looks like errno == 251 if line is
* finished with EOF and errno == 25 if there is nothing left
* to read.
* finished with EOF and errno == 25 (EINVAL on Mac) if there is
* nothing left to read.
*/
if (errno == 251 || errno == 25)
if (errno == 251 || errno == 25 || errno == EINVAL)
errno = 0;
if (!linep)
return NULL;
@ -407,13 +407,12 @@ Process(JSContext *cx, JSObject *obj, char *filename, JSBool forceTTY)
size_t len = 0; /* initialize to avoid warnings */
do {
ScheduleWatchdog(cx->runtime, -1);
#ifdef JS_THREADSAFE
jsrefcount rc = JS_SuspendRequest(cx);
#endif
gCanceled = false;
errno = 0;
char *line = GetLine(file, startline == lineno ? "js> " : "");
if (!line) {
JS_ResumeRequest(cx, rc);
if (errno) {
JS_ReportError(cx, strerror(errno));
free(buffer);
@ -437,6 +436,7 @@ Process(JSContext *cx, JSObject *obj, char *filename, JSBool forceTTY)
if (!newBuf) {
free(buffer);
free(line);
JS_ResumeRequest(cx, rc);
JS_ReportOutOfMemory(cx);
return;
}
@ -450,9 +450,7 @@ Process(JSContext *cx, JSObject *obj, char *filename, JSBool forceTTY)
free(line);
}
lineno++;
#ifdef JS_THREADSAFE
JS_ResumeRequest(cx, rc);
#endif
if (!ScheduleWatchdog(cx->runtime, gTimeoutInterval)) {
hitEOF = JS_TRUE;
break;
@ -2758,9 +2756,7 @@ EvalInContext(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
JS_SetOptions(scx, JS_GetOptions(cx));
#ifdef JS_THREADSAFE
JS_BeginRequest(scx);
#endif
src = JS_GetStringChars(str);
srclen = JS_GetStringLength(str);
lazy = JS_FALSE;
@ -2803,9 +2799,7 @@ EvalInContext(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
out:
#ifdef JS_THREADSAFE
JS_EndRequest(scx);
#endif
WITH_LOCKED_CONTEXT_LIST(
JS_DestroyContextNoGC(scx)
);
@ -4504,9 +4498,7 @@ main(int argc, char **argv, char **envp)
if (!cx)
return 1;
#ifdef JS_THREADSAFE
JS_BeginRequest(cx);
#endif
glob = JS_NewObject(cx, &global_class, NULL, NULL);
if (!glob)
@ -4601,9 +4593,7 @@ main(int argc, char **argv, char **envp)
}
#endif /* JSDEBUGGER */
#ifdef JS_THREADSAFE
JS_EndRequest(cx);
#endif
WITH_LOCKED_CONTEXT_LIST(
JS_DestroyContext(cx)