嵌入Spidermonkey-segfault

时间:2019-03-26 11:36:30

标签: c++ dynamic-linking spidermonkey

我正在尝试将Spider Monkey嵌入C ++代码中。下载了https://ftp.mozilla.org/pub/spidermonkey/prereleases/60/pre3/mozjs-60.1.1pre3.tar.bz2

按照INSTALL../configure --enable-debug --disable-optimize中的说明进行编译。我的示例应用程序如下所示:

#include <iostream>
#include <stdexcept>
#include "jsapi.h"
#include "js/Initialization.h"

int main(int argc, char** args) {
    if (!JS_Init()) {
        throw std::runtime_error("failed to initialise.");  
    }

    std::cout << "It's alive!\n";

    JS_ShutDown();
    return 0;
}

我的g ++ cmd看起来像这样:

g++ -DDEBUG -I${HOME}/mozjs-60.1.1pre3/js/src/obj/dist/include -L${HOME}/mozjs-60.1.1pre3/js/src/obj/dist/bin/ main.cpp  -lmozjs-60 -lm -lz -ldl

运行后(我需要LD_PRELOAD才能启动),我得到了瞬时SIGSEGV。这是回溯:

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff5b9504a in js::Mutex::Mutex (
    this=0x7ffff7dcdbc0 <js::jit::CacheIRSpewer::cacheIRspewer>, id=...)
    at /home/m.radwanski/code/mozjs-60.1.1pre3-dynamic/mozjs-60.1.1pre3/js/src/threading/Mutex.h:57
#2  0x00007ffff5db9109 in js::jit::CacheIRSpewer::CacheIRSpewer (
    this=0x7ffff7dcdbc0 <js::jit::CacheIRSpewer::cacheIRspewer>)
    at /home/m.radwanski/code/mozjs-60.1.1pre3-dynamic/mozjs-60.1.1pre3/js/src/jit/CacheIRSpewer.cpp:34
#3  0x00007ffff5e29df0 in __static_initialization_and_destruction_0 (__initialize_p=1, 
    __priority=65535)
    at /home/m.radwanski/code/mozjs-60.1.1pre3-dynamic/mozjs-60.1.1pre3/js/src/jit/CacheIRSpewer.cpp:31
#4  0x00007ffff5e2f444 in _GLOBAL__sub_I_Unified_cpp_js_src13.cpp(void) ()
    at /home/m.radwanski/code/mozjs-60.1.1pre3-dynamic/mozjs-60.1.1pre3/js/src/jit/CompileWrappers.cpp:303
#5  0x00007ffff7de5733 in call_init (env=0x7fffffffdfc8, argv=0x7fffffffdfb8, argc=1, 
    l=<optimized out>) at dl-init.c:72
#6  _dl_init (main_map=0x7ffff7ffe170, argc=1, argv=0x7fffffffdfb8, env=0x7fffffffdfc8)
    at dl-init.c:119
#7  0x00007ffff7dd60ca in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#8  0x0000000000000001 in ?? ()
#9  0x00007fffffffe2c8 in ?? ()
#10 0x0000000000000000 in ?? ()

我做错了什么?

0 个答案:

没有答案