Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jxcore crashed at JX_CreateEmptyObject in sub instance creation thread #914

Open
yongxin100 opened this issue Oct 11, 2016 · 0 comments
Open

Comments

@yongxin100
Copy link

yongxin100 commented Oct 11, 2016

Hi
I am currently working on embedding jxcore to my robotic system program.When i am testing embedding api ,i produced the following code:

include "stdafx.h"

include "ScriptEngine.h"

include <windows.h>

include "thread"

include "mutex"

int main(int argc, char **args) {

char* homeFolder = args[0];


JX_InitializeOnce(homeFolder);
JX_InitializeNewEngine();

JX_DefineMainFile("console.log('parent engine')");

JXValue obj;

  **# // Parent engine created at main thread ,and JX_CreateEmptyObject worked ok!**
JX_CreateEmptyObject(&obj); 
JXValue global;
JX_GetGlobalObject(&global);
JX_SetNamedProperty(&global, "NativeBridge", &obj);
JX_Free(&obj);
JX_Free(&global);

JX_StartEngine();


//create a new engine instance and attach it to a new thread
thread t1 (create_new_engine);
t1.join();




Sleep(10 * 1000);

}

void create_new_engine() {

string homeFolder = "";
JX_InitializeNewEngine();

JX_DefineMainFile("console.log('sub engine')");

JX_StartEngine();

JXValue obj1;

  **# // sub engine created at new  thread ,and JX_CreateEmptyObject called fail!**

     //Exception thrown: read access violation.
     //__imp_TlsGetValue(...) returned nullptr.

    //program break at :
   //JXCORE_EXTERN(bool)
    //JX_CreateEmptyObject(JXValue *value) {
    // node::commons *com = node::commons::getInstance();

JX_CreateEmptyObject(&obj1);
JXValue global;
JX_GetGlobalObject(&global);
JX_SetNamedProperty(&global, "NativeBridge", &obj1);


JX_Free(&obj1);
JX_Free(&global);

JX_Loop();

JX_StopEngine();

}

My working enviroment is : windows 10 ,visual studio 2015,runing in vm fusion on mac

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant