- Home /
Using Phidgets the Editor crashes on second play from acces read violation, execption code 0xC0000005
I wrote a script for reading out a phidget. With the data i control a simple ball, whenever i press play it works without a problem. But after quitting the play mode waiting a few sec and pressing start again the editor will crash and give de read violation.
This is thread is probably the cause of the problem.
//Separate thread to start Phidget connection
private IEnumerator PhidgetThread()
{
try
{
ifk_DI = new DigitalInput[8];
ifk_DO = new DigitalOutput[8];
ifk_AI = new VoltageInput[8];
for (int i = 0; i < 8; i++)
{
ifk_DI[i] = new DigitalInput();
ifk_DI[i].Channel = i;
ifk_DI[i].Open(5000);
ifk_DO[i] = new DigitalOutput();
ifk_DO[i].Channel = i;
ifk_DO[i].Open(5000);
ifk_AI[i] = new VoltageInput();
ifk_AI[i].Channel = i;
ifk_AI[i].Open(5000);
ifk_AI[i].DataInterval = 2;
}
Debug.Log("Controller is ready for use");
}
catch (PhidgetException ex)
{
for (int i = 0; i < 8; i++)
{
if (ifk_DI[i] != null || ifk_DO[i] != null || ifk_AI[i] != null)
{
ifk_DI[i].Close();
ifk_DO[i].Close();
ifk_AI[i].Close();
}
}
Debug.Log("I has errors");
Debug.LogError(ex.Message);
}
Debug.Log("Yield break");
yield break;
}
the onapplicationquit with the following code to close the channels.
private void OnApplicationQuit()
{
for (int i = 0; i < 8; i++)
{
ifk_DI[i].Close();
ifk_DO[i].Close();
ifk_AI[i].Close();
}
Debug.Log("All channels are closed");
}
Answer by unity_B2XGWtBRxTJexQ · Oct 25, 2017 at 07:34 AM
The problem is fixed. Apperently it just had something to do with updating Unity since it was some kind of memory leak in the mono-2.0-bdwgc.dll.
Your answer
Follow this Question
Related Questions
Initialising List array for use in a custom Editor 1 Answer
Can I auto run a script when editor launches or a project finishes loading? 4 Answers
Apparent Problem with smartfox crashing unity editor 0 Answers
unity3d editor crashes a lot. Is there a preferences reset 0 Answers
Editor Crash : nvwgf2um.dll caused an Access Violation 0 Answers