Sign in to follow this  
Canberk S

Using AngelScript in Multithreaded Applications

Recommended Posts

Canberk S    115

Hi guys! I'm trying to write a simple GUI-based interpreter for AngelScript to be used in my future projects. It uses multithreading. The multithreading support is provided by wxWidgets. Problem is that even I try to execute just a little piece of code (script), it crashes. My application is programmed to run just one script at once. It's using asIScriptEngine in MyFrame class, so it's not created every script execution session. In each script execution thread, asIScriptContext is created, so the same context is not used for every script execution session. But it's not running sad.png. Help me plz.
My system configuration :
I'm working under x64 Linux environment, my distro is Ubuntu 12.04. I'm using g++ 4.6.3. My GUI toolkit is wxWidgets 2.9.5 . I compiled it my own. My AngelScript version is 2.28.0 . I'm using CodeBlocks IDE. I have rewritten scriptstdstring add-on to work with wxString.

The source code of the application is attached.

Share this post


Link to post
Share on other sites
WitchLord    4677

I took a quick look at your code, but I didn't find any immediately evident problem in the code you've written. 

 

Can you provide more information on the crash you experience? Perhaps show the callstack? Have you tried debugging the code to see where exactly the code crashes?

Share this post


Link to post
Share on other sites
Canberk S    115

Yes, of course. According to the output of debugging, it was an crash caused by X Window System. It seems insane, because as I know, wxThread is based on POSIX Threads. Even I make wxalert(wxString &msg) function an empty function, I get similar errors. The crash usually happens when "m_frm->m_scriptcontext->Execute();" is executed. Then I thought that the crash is caused by wxWidgets logging system. Then I commented "wxLog..." lines. But it didn't work. Perhaps the problem is because of my wrong multithreading usage. Could you provide me an application using AngelScript with pthreads ? If it works on my computer, it will show that the problem is caused by wxWidgets. By the way, I modified and used scriptstdstring to work with wxString. Maybe the problem is caused by it. I attach it.

Share this post


Link to post
Share on other sites
WitchLord    4677

Unfortunately I have no Linux application that uses multithreading. AngelScript itself doesn't create any threads, it only uses pthread_mutex_t and pthread_rwlock_t for critical sections to avoid concurrency problems if the application uses multiple threads when accessing the engine.

 

If you suspect the problem is with the wxThread, why not exchange it for normal pthreads instead and see if that works? Or even eliminate the extra thread altogether just to see if it is a problem with multithreading or something else entirely.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this