Open Bug 1172303 Opened 8 years ago Updated 1 year ago

spidermonkey jsapi JS::Compile Segmentation Fault

Categories

(Core :: JavaScript Engine, defect)

31 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: sisciamirror, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

1.40 KB, text/x-c++src
Details
Attached file test.cpp
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>    
```
Component: Embedding: APIs → JavaScript Engine
Blocks: jsapi
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.