Spidermonkey 1.8.5在调试模式下崩溃
spidermonkey 1.8.5 crashes in debug mode
我在应用程序中使用Spidermonkey 1.8.5。当我使用调试JS库时,应用程序崩溃了。我正在用以下选项构建库:——启用调试——禁用优化——启用threadsafe
crash指向这里:断言失败:(cx)->thread->data。requestDepth | | (cx) ->线程= = (cx) ->运行> gcThread,在. ./. ./src/jsapi.cpp
下面是示例程序/* Include the JSAPI header file to get access to SpiderMonkey. */
#include "jsapi.h"
/* The class of the global object. */
static JSClass global_class = {
"global", JSCLASS_GLOBAL_FLAGS,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
};
/* The error reporter callback. */
void reportError(JSContext *cx, const char *message, JSErrorReport *report)
{
fprintf(stderr, "%s:%u:%sn",
report->filename ? report->filename : "<no filename="filename">",
(unsigned int) report->lineno,
message);
}
int main(int argc, const char *argv[])
{
/* JSAPI variables. */
JSRuntime *rt;
JSContext *cx;
JSObject *global;
printf("Startedn");
/* Create a JS runtime. You always need at least one runtime per process. */
rt = JS_NewRuntime(8 * 1024 * 1024);
if (rt == NULL)
return 1;
/*
* Create a context. You always need a context per thread.
* Note that this program is not multi-threaded.
*/
cx = JS_NewContext(rt, 8192);
if (cx == NULL)
return 1;
JS_SetErrorReporter(cx, reportError);
/*
* Create the global object in a new compartment.
* You always need a global object per context.
*/
global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);
if (global == NULL)
return 1;
/*
* Populate the global object with the standard JavaScript
* function and object classes, such as Object, Array, Date.
*/
if (!JS_InitStandardClasses(cx, global))
return 1;
/* Your application code here. This may include JSAPI calls
* to create your own custom JavaScript objects and to run scripts.
*
* The following example code creates a literal JavaScript script,
* evaluates it, and prints the result to stdout.
*
* Errors are conventionally saved in a JSBool variable named ok.
*/
char *script = "'Hello ' + 'World!'";
jsval rval;
JSString *str;
JSBool ok;
const char *filename = "noname";
uintN lineno = 0;
ok = JS_EvaluateScript(cx, global, script, strlen(script),
filename, lineno, &rval);
if (rval == NULL | rval == JS_FALSE)
return 1;
str = JS_ValueToString(cx, rval);
printf("%sn", JS_EncodeString(cx, str));
/* End of your application code */
/* Clean things up and shut down SpiderMonkey. */
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
JS_ShutDown();
return 0;
}
如果我在发布模式下构建,程序工作正常。这个问题只在调试模式下出现。我遗漏了什么?
在JS_NewCompartmentAndGlobalObject
调用之前插入JS_BeginRequest(cx);
在调用JS_DestroyContext
之前插入JS_EndRequest(cx);
。
大多数JSAPI函数都需要请求。(我不知道为什么。使用线程的最初原因与多线程有关,但现在每个JSRuntime都是单线程的。
SpiderMonkey的调试版本包含了一些断言,这些断言可以以发布模式不能的方式检查API的使用情况。因此,您可能会再次看到只调试的断言。我强烈建议根据调试构建进行开发,因为这些断言几乎总是指出真正的问题。
下一个SpiderMonkey版本即将发布:https://bugzilla.mozilla.org/show_bug.cgi?id=735599#c54
相关文章:
- LoadLibrary:在发布模式下崩溃
- 在发布模式下崩溃,但如果可调试为 true - 不是..什么是可能的问题
- boost :: container :: flat_multimap在OSX/Appleclang上以发行模式崩溃
- MSVC 编译器在调试模式下构建 Qt 5.10 时崩溃
- 一般来说,使用Qt Creator,是什么导致程序在调试模式下编译时正确运行,但在发布模式下崩溃
- 在发行模式下开放的软崩溃(调试工作正常)
- MFC 结束对话框崩溃时模式对话框没有焦点
- GCC 在调试模式下崩溃,在发布模式下运行良好
- 在发布模式下崩溃,在调试模式下遇到错误
- C++: __try..__除了;在发布模式下隐藏崩溃
- 通过在 C++ 中使用发布模式二进制文件获取崩溃原因
- cd库:在推送自定义类型的派生类型时(仅在发布模式下),michael_deque会导致崩溃
- wglCreateContextAttribsARB在x64平台下的调试模式下崩溃
- 当结构具有默认构造函数时,为什么我的C++程序在发布模式下崩溃
- boost::any_range<gsl::string_span<>> 在发布模式下崩溃
- 释放模式下的boost线程崩溃
- OCCI应用程序在Visual Studio 2005的调试模式下运行时会崩溃
- c++全系统崩溃,仅发布模式
- Directshow渲染过滤器只在发布模式下崩溃
- Visual Studio 2008-vftable指针不正确?调试模式崩溃,发布即可