Jump to content

[SOLVED] Crash of application.


photo

Recommended Posts

I am loading the world through unigine as following,
 
char cWorldPath[] = "world_load XYZ/XYZ";
Unigine::Engine *engine = Unigine::Engine::get();
Unigine::Console * console = Unigine::Console::get();
console->setActivity(1);
console->run(cWorldPath);
console->flush();
console->setActivity(0);


int iNumPlugin = engine->findPlugin("MyPlugin");
MyPlugin *pPlugin = (MyPlugin*) engine->getPluginData(iNumPlugin);
pPlugin->isWorldLoad();  // this function checks world is loaded or not and if loaded it loads tracks. 
 
everything is fine so far, but when I load the second world through the same process and try to call the plugin functions for rendering I get an Assertion as follows,
 
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!
 
Program: ...
File: U:\source\engine\EngineInterpreter.h
Line: 86
 
Expression: depth < NUM_INSTANCES && "EngineInterpreterInstance::begin(): stack overflow"
 
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts
 
(Press Retry to debug the application - JIT must be enabled)
---------------------------
Abort   Retry   Ignore   
---------------------------
 
I tried debugging throught the code and figured out that the problem seems to be in,
 
void Machine::run(int begin,Interpreter::Context *context)
 
which throws an access violation 
 
First-chance exception at 0x000007fed3f91e56 (.dll) in XYZ .exe: 0xC0000005: Access violation reading location 0x0000000000000208.
 
on evey call to it, the trace to which is as follows,
TRACE:
Machine::run(int begin, Interpreter::Context * context)  Line 57 C++
Interpreter::runFunction(int function, int num_args, const Variable * args)  Line 6545 C++
Interpreter::runFunction(const char * name, int num_args, const Variable * args)  Line 6475 C++
Interpreter::runFunction(const Variable & name, int num_args, const Variable * args)  Line 6470 C++
Unigine::run_system_function(const Unigine::Variable & name)  Line 1144 + 0x19 bytes C++
MyPlugin.dll!MyPlugin::cut()  Line 41 + 0x40 bytes C++
MyPlugin.dll!MyPlugin::setIndex(SWITCHER_LAYER _layer)  Line 78 C++
 
the execution is lost from the SWITCH case not sure where exactly but mostly in the CASE(CALLECFR).
So what am I missing here, is there any closing steps needed to be undertaken before loading a new world or any reinitialization required before calling plugin functions?

 

Link to comment
  • 2 weeks later...

Hi Andrey,
Thanks for reply,
I will provide you an exact scenario of our application and same plugin code.

codes in the first thread is

//These code are continously executed
Unigine::Engine *engine = Unigine::Engine::get();
int iNumPlugin = engine->findPlugin("MyPlugin");
MyPlugin *pPlugin = (MyPlugin*) engine->getPluginData(iNumPlugin);
while(1)
{
   pPlugin->cut();
}

In other thread

//Executed for loading world
char cWorldPath[] = "world_load XYZ/XYZ";
Unigine::Engine *engine = Unigine::Engine::get();
Unigine::Console * console = Unigine::Console::get();
console->setActivity(1);
console->run(cWorldPath);
console->flush();

Plugin

void MyPlugin::cut()
{
  Unigine::Engine *engine = Unigine::Engine::get();
  engine->runSystemFunction("cut");
}
int MyPlugin::init()
{
   MyPlugin  m_MyPluginObj;
   Unigine::Interpreter::addExternLibrary("m_MyPluginObj");
   Unigine::Interpreter::addExternFunction("m_MyPluginObj.cut",MakeExternObjectFunction(m_MyPluginObj,&MyPlugin::cut));
return 1;
}

System Script

 

using Unigine::Tracker;
Unigine::Tracker::TrackerTrack track;
Tracker tracker = new Tracker();
void cut() { track = tracker.loadTrack(trackPath[selection]); //different tracks are being loaded
track.set(1.0f);
}

It works fine until the first time the world is loaded while loading the second time it crashes.

if I comment the code:-

track.set(1.0f);

in script side then the application do not crash but I need to set time for track.

 

Thanks.

Link to comment

hi

Finally, it's resolved, as it needs to delete track variable each time world gets unload in world shutdown and should be recreated each time a new world is loaded to avoid memory leakage.

  • Like 1
Link to comment
×
×
  • Create New...