Re: How to create a new runtime in spidermonkey 60
msami <[email protected]> Thu, 15 Aug 2019 02:11:41 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
Thanks for your reply, I created 2 instances Segmentation fault happenn on constructor
MozillaJSEngine::MozillaJSEngine():cx(JS_NewContext(JS::DefaultHeapMaxBytes)), global(cx), scopeChain(cx) {
if (!cx) {
}
if (!JS::InitSelfHostedCode(cx)) {
}
JS::SetWarningReporter(cx, MozillaJSEngine::reportWarning);
JSAutoRequest ar(cx);
global = MozillaJSEngine::createGlobal(GLOBAL);
setCurrentScope(GLOBAL);
}
MozillaJSEngine::~MozillaJSEngine() {
rootedObjectsMap.clear();
JS_DestroyContext(cx);
}
bool MozillaJSEngine::init() {
bool ok = true;
if (!JS_Init()) {
ok = false;
}
return ok;
}'
## valgrind
==5737== Invalid write of size 4
==5737== at 0x4D32AFE: js::NewContext(unsigned int, unsigned int, JSRuntime*) (JSContext.cpp:147)
==5737== by 0x10C637: MozillaJSEngine::MozillaJSEngine() (MozillaJSEngine.cpp:12)
==5737== by 0x10B06E: VxmlJsEngine::VxmlJsEngine() (VxmlJsEngine.cpp:13)
==5737== by 0x10C373: main (main.cpp:27)
==5737== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==5737==
==5737==
==5737== Process terminating with default action of signal 11 (SIGSEGV)
==5737== Access not within mapped region at address 0x0
==5737== at 0x4D32AFE: js::NewContext(unsigned int, unsigned int, JSRuntime*) (JSContext.cpp:147)
==5737== by 0x10C637: MozillaJSEngine::MozillaJSEngine() (MozillaJSEngine.cpp:12)
==5737== by 0x10B06E: VxmlJsEngine::VxmlJsEngine() (VxmlJsEngine.cpp:13)
==5737== by 0x10C373: main (main.cpp:27)
==5737== If you believe this happened as a result of a stack
==5737== overflow in your program's main thread (unlikely but
==5737== possible), you can try to increase the size of the
==5737== main thread stack using the --main-stacksize= flag.
==5737== The main thread stack size used in this run was 8388608.
==5737==
==5737== HEAP SUMMARY:
==5737== in use at exit: 1,769,041 bytes in 2,353 blocks
==5737== total heap usage: 6,549 allocs, 4,196 frees, 3,708,737 bytes allocated
==5737==
==5737== LEAK SUMMARY:
==5737== definitely lost: 0 bytes in 0 blocks
==5737== indirectly lost: 0 bytes in 0 blocks
==5737== possibly lost: 2,060 bytes in 34 blocks
==5737== still reachable: 1,766,981 bytes in 2,319 blocks
==5737== suppressed: 0 bytes in 0 blocks
==5737== Rerun with --leak-check=full to see details of leaked memory
==5737==
==5737== For counts of detected and suppressed errors, rerun with: -v
==5737== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault