Open Bug 1172303 Opened 5 years ago Updated 5 years ago
spidermonkey jsapi JS::Compile Segmentation Fault
Very new about all this, most likely the problem is just me doing something wrong. Anyway I am trying to use SpiderMonkey as embedded library, the first thing I am trying to do is to compile a JS string. However I got a simple segmentation fault between the printf 2 and 3 of the attached file. What I am doing wrong ? ``` bash simo@simo:~/ulambda/C$ file /usr/local/lib/libmozjs-31.so /usr/local/lib/libmozjs-31.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=89cc00391ff60647984f4e74d9a41b0dde453a95, not stripped simo@simo:~/ulambda/C$ g++ -std=c++11 -I/home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/include -L/home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/lib test.cpp -o helloworld -lmozjs-31 -lz -lpthread -ldl -g In file included from /usr/include/string.h:32:0, from /home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/include/js/Utility.h:19, from /home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/include/jsalloc.h:18, from /home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/include/jsapi.h:21, from test.cpp:1: /home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/include/jspubtd.h:432:74: warning: invalid access to non-static data member ‘js::PerThreadDataFriendFields::RuntimeDummy::mainThread’ of NULL object [-Winvalid-offsetof] static const size_t RuntimeMainThreadOffset = offsetof(RuntimeDummy, mainThread); ^ /home/simo/mozjs-31.2.0/js/src/build_DBG.OBJ/dist/include/jspubtd.h:432:74: warning: (perhaps the ‘offsetof’ macro was used incorrectly) [-Winvalid-offsetof] simo@simo:~/ulambda/C$ file helloworld helloworld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=17b3d123e446a85cad54145d3c151b040abf4d6b, not stripped simo@simo:~/ulambda/C$ ./helloworld 1 2 Segmentation fault (core dumped) simo@simo:~/ulambda/C$ simo@simo:~/ulambda/C$ simo@simo:~/ulambda/C$ js js> version() 185 js> ```
You need to log in before you can comment on or make changes to this bug.