Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Weird Unity crash (DLL related)

Discussion in 'Editor & General Support' started by BenouKat, Mar 17, 2015.

  1. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hi everyone,

    I use the libogg.dll, libvorbis.dll and libvorbisfile.dll in my project. They are 32 bit dll, so I had to download the 32 bit editor cause the DLL can't be read if not. The DLLs are working fine I can call functions without problems.

    This is my code part I try to debug. I sum it up cause the problem is not code related, more DLL related. You will understand.

    I wrote this into a Coroutine :

    Code (CSharp):
    1. long bytesRead = NativeMethods.ov_read(ref oggfile, bufferIntPtr, 4096, 0, pcmWordSize, 1, ref logicalBitstreamRead);
    2. int framePause = 0;
    3.  
    4. while (bytesRead > 0) {
    5.                 // I do my stuff...
    6.  
    7.                 if(framePause >= 10) //the frame pause limit, here = 10 loop / frame
    8.                 {
    9.                             framePause = 0;
    10.                             yield return new WaitForSeconds(1f);
    11.                  }
    12.                  bytesRead = NativeMethods.ov_read(ref oggfile, bufferIntPtr, 4096, 0, pcmWordSize, 1, ref logicalBitstreamRead);
    13. }

    NativeMethod.ov_read is a function from a DLL. All the params are correctly set earlier. The problem is not here. The problem is my Unity crash when I call "ov_read", the DLL function. BUT, not always !

    This code will run 10 loop then wait for a second. Then : unity crash when ov_read is called at line 12. Like you will, I smell a classic IO error problem.

    So i change my framePause limit line 7, and set 1 instead of 10. So the code pause every loop. I run it, first loop ok, waiting a seconde, then unity crash when ov_read is called line 12.

    No matter what number I set the framePause limit I set, everytime the code pause for one second, ov_read crash unity immediatly after.
    So it's not a file or read file problem, cause I can read it 10 times in the first situation, so why not 2 times in the second try ?

    There's more : if I set a higher number, like 50, the loop doesn't reach the pause and crash before.

    I check the editor log and this is the stack trace :


    Can someone help me, or at least tells me what's wrong ?

    Thanks a lot community, please save my day :)
     
  2. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    I read some documentation about ov_read, I was wondering if it's thread related. But the documentation is pretty clear, it's not.

    I don't understand why pause the code result to a crash when I call my function after that. And why the editor logs say that there's a failure with my DLL ? The DLL seems to be "unlink" during runtime ?

    Thanks for anyone who can help
     
  3. leonardomt

    leonardomt

    Joined:
    Jul 8, 2015
    Posts:
    1
    Hello Benoukat, have you found a solution or further explanation for this error? Thanks
     
  4. Jason-Michael

    Jason-Michael

    Joined:
    Jul 6, 2015
    Posts:
    20
    seems i got the same problem too and i'm googling for a workaround, but still not solved yet,