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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question GameAssembly.dll Access violation reading location ....

Discussion in 'Windows' started by hein30, Oct 27, 2020.

  1. hein30

    hein30

    Joined:
    Nov 8, 2018
    Posts:
    11
    Unity 2019.4.11f1

    I am getting access violation exception randomly when I try to use a large image array returned from window runtime component's method.

    There is no exception when I don't try to access that large array. (i.e. if i comment out
    Code (CSharp):
    1. var array = e.imageArray;
    , I don't get any exception).

    Code (CSharp):
    1.  #if ENABLE_WINMD_SUPPORT
    2.      void OneFrameAvailable(object sender, RMFrameData e){
    3.          ++frameCounter;
    4.          var height = e.height;
    5.          var width = e.width;
    6.          var array = e.imageArray;
    7.        
    8.        
    9.          Enqueue(() => {
    10.          if (tex == null)
    11.                      {
    12.                          tex = new Texture2D(width, height, TextureFormat.BGRA32, false);
    13.                          material.mainTexture = tex;
    14.                      }
    15.                      tex.LoadRawTextureData(e.imageArray);
    16.                      tex.Apply();
    17.      });
    18.      }
    19. #endif
    I've attached screenshots of call stack and breakpoint of where the exception is been thrown.

     
    Last edited: Oct 27, 2020
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Can you show the implementation of RMFrameData? A crash inside the garbage collector usually means memory corruption.
     
  3. hein30

    hein30

    Joined:
    Nov 8, 2018
    Posts:
    11
    Completely newbie in C++ and trying to write the WRC.

    FMFrameData.idl
    Code (CSharp):
    1. runtimeclass RMFrameData
    2.     {
    3.         BYTE[] imageArray;
    4.     }
    #FrameData.h
    Code (CSharp):
    1. struct FrameData : FrameData <RMFrameData>
    2. {
    3.    RMFrameData() = default;
    4.    ~RMFrameData();
    5.  
    6.    com_array<uint8_t>& imageArray();
    7.    void imageArray(array_view<uint8_t const> value);
    8.  
    9. private:
    10.    com_array<uint8_t> m_imageArray{};
    11. };
    #FrameData.cpp

    Code (CSharp):
    1. RMFrameData::~RMFrameData()
    2. {
    3.     m_imageArray.clear();
    4. }
    5. com_array<uint8_t>& RMFrameData::imageArray()
    6. {
    7.    return m_imageArray;
    8. }
    9. void RMFrameData::imageArray(array_view<uint8_t const> value)
    10. {
    11.    m_imageArray = winrt::com_array<BYTE>(std::move_iterator(value.begin()), std::move_iterator(value.end()));
    12. }
    Method sending RMFrameData
    Code (CSharp):
    1. void PVProcessor::OnFrameArrived(const MediaFrameReader& sender, const MediaFrameArrivedEventArgs& args)
    2.    {
    3.  
    4.        if (MediaFrameReference frame = sender.TryAcquireLatestFrame())
    5.        {
    6.            auto frame_data = winrt::make_self<winrt::HL2CV_WRT::implementation::RMFrameData>();
    7.  
    8.            if (frame != nullptr && frame.VideoMediaFrame() != nullptr) {
    9.  
    10.                uint32_t pixelBufferDataLength = 0;
    11.                uint8_t* pixelBufferData;
    12.                SoftwareBitmap bitmap = SoftwareBitmap::Convert(frame.VideoMediaFrame().SoftwareBitmap(), BitmapPixelFormat::Bgra8);
    13.                if (bitmap != nullptr) {
    14.                    BitmapBuffer bitmapBuffer = bitmap.LockBuffer(BitmapBufferAccessMode::Read);
    15.  
    16.                    auto spMemoryBufferByteAccess{ bitmapBuffer.CreateReference().as<::Windows::Foundation::IMemoryBufferByteAccess>() };
    17.                    winrt::check_hresult(spMemoryBufferByteAccess->GetBuffer(&pixelBufferData, &pixelBufferDataLength));
    18.  
    19.                    std::vector<BYTE> pixelVectorData{};
    20.                    pixelVectorData.insert(pixelVectorData.end(), std::make_move_iterator(pixelBufferData), std::make_move_iterator(pixelBufferData + pixelBufferDataLength));
    21.                    frame_data->imageArray(pixelVectorData); //set com_array here.
    22.                    bitmap.Close();
    23.                }
    24.  
    25.            }
    26.            frame.Close();
    27.            m_frame_data_available(*this, *frame_data);
    28.        }
    29.    }
    Sorry, I don't know how to format it in C++. Thanks for your help.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    That looks reasonable although I'm not too familiar with C++/WinRT library.

    Anyway, there are two ways forward: either we can debug on your side, or you can submit the bug to us and we can dig into it. Since it might take a while for us to be able to look at this, I suggest we continue debugging on your side for now.

    Open up admin command prompt and enter this (replace Game.exe with the exe name for your game - not the path, just the file name):

    Code (csharp):
    1. appverif -enable Exceptions Handles Heaps Leak Locks Memory Threadpool TLS -for Game.exe
    This enables Application Verifier, which is a debugging tool for finding incorrect code.

    Then, run your game from Visual Studio again. With any luck, it will lead to a crash earlier, with the culprit caught red handed. Once done, don't forget to disable it for you app again as it has a big performance impact:

    Code (csharp):
    1. appverif -disable * -for Game.exe
     
  5. hein30

    hein30

    Joined:
    Nov 8, 2018
    Posts:
    11
    Thanks for your quick reply. But it does not look like HoloLens can run application verifier or am I missing something?
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Oh, can you not reproduce it on PC?
     
  7. hein30

    hein30

    Joined:
    Nov 8, 2018
    Posts:
    11
    No, the windows runtime component is using the sensors available on HoloLens 2. Thank you so much for your help.
     
  8. chris_gsa

    chris_gsa

    Joined:
    Aug 1, 2019
    Posts:
    10
    Hi, is there any update on this? Were you able to resolve the problem?

    I'm running into a very similar issue with my Windows Runtime Component using Unity / HoloLens 2.
     
  9. sensevividus

    sensevividus

    Joined:
    Jun 25, 2019
    Posts:
    1
    hi, I'm running into the same issue too. how did you solve this issue?
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    What exactly are you running into?
     
  11. ARGs_code

    ARGs_code

    Joined:
    May 7, 2019
    Posts:
    12
    GC collection in GameAssembly.dll is now causing crashes in my Hololens 2 applications, as described above.

    These builds worked fine as of yesterday, but after making a change to an image asset only, builds now break and throw this exception when debugging. This issue only occurs on the Hololens 2 and does not occur in the Unity Editor.

    upload_2023-2-17_10-55-2.png

    Unhandled exception at 0x00007FFE2F3114C8 (GameAssembly.dll) in RefractionProto.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x0000000DDE603CB0).

    I do not know if this is related, but my machine recently applied a windows update and I also pulled the latest Windows10 SDKs to get everything up to date, shortly after this issue began appearing in every single build I have attempted for deployment to Hololens 2, regardless of the project.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Do you have a callstack? Could it be an infinite recursion problem in your code?
     
  13. ARGs_code

    ARGs_code

    Joined:
    May 7, 2019
    Posts:
    12
    The problem only occurs on the Hololens 2. I don't have any infinite recursion problems in the editor or in my code as far as I can tell. The application crashes within 1 second of starting, throws no errors.

    As a sanity check I built an empty scene with just the MRTK Toolkit in it and deployed it to the Hololens 2 and, I am getting the exact same issue.

    Here's the call stack: https://hastebin.com/share/apexevegay.markdown

    This error is not from my code. This appears to be a Unity Script causing this. Unity.InputSystem.InputControl
     
    Last edited: Feb 21, 2023
  14. ARGs_code

    ARGs_code

    Joined:
    May 7, 2019
    Posts:
    12
    After digging back through my build logs, I have also found the following:

    Warning C4717 'InputOptions_set_Headers_m6A1DF761971E6AA0F44B86DBCE8CD0846F0AF063': recursive on all control paths, function will cause runtime stack overflow Il2CppOutputProject A:\Docs\Builds\SanityCheck\Il2CppOutputProject\Source\il2cppOutput\Assembly-CSharp4.cpp 33994

    Again, this appears to be a Unity Script which I have not written or touched. But I am unsure.
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Assembly-CSharp4.cpp suggests that this code is part of your C# scripts. Do you have a class named "InputOptions" which has a property named "Headers"?
     
  16. ARGs_code

    ARGs_code

    Joined:
    May 7, 2019
    Posts:
    12
    It turns out I do. It looks like this is part of Azure Cognitive Services Unity Text To Speech script I was passed for this project.

    Pertinent parts of the script are here:

    https://hastebin.com/share/liqemuxowo.csharp

    However it is still odd that this issue only appeared this week and the last time this script was changed was 288 days ago. My output format and authorization token have also not changed.

    Looks like I will go figure out who sourced this on the team.
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Commenting out that "Headers = value;" line should fix it. It doesn't look like the getter is trying to retrieve a saved value anyway.
     
  18. DevinW

    DevinW

    Joined:
    Jun 19, 2014
    Posts:
    36
    Ran into the same issue on my Hololens 2 project using Azure Spatial Anchors.

    "Exception thrown at 0x00007FF8A2EDCF34 (GameAssembly.dll) in WLASA.exe: 0xC0000005: Access violation reading location 0x0000000000000008."
    upload_2023-3-23_14-53-33.png
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Can you report a bug on this?
     
  20. KALMAN_FILTER

    KALMAN_FILTER

    Joined:
    Apr 10, 2023
    Posts:
    3
    Any update on this topic ?
    I tried downloading GameAssembly.dll and installed it in window/system32 but the issue found not solved.
    P.S. I am debuging on Virtual Studio S2019 and will be deploying my project to Hololens2. Bug found 10042023.png
     
  21. DivinorWieldor

    DivinorWieldor

    Joined:
    Aug 24, 2021
    Posts:
    2
    Hello, seems to be no further progress on this but I wanted to pitch in as well to report error on my end. I'm currently getting the same error Kalman reported above.

    I have a completely new project freshly installed with MRTK in Unity 2021.3.20f1. When I set up an empty scene (that has been configured for MRTK), build it to VS2019, then run the .sln file to deploy on my hololens 2, I receive these:
    Unhandled exception at 0x00007FFE859A8948 (GameAssembly.dll) in PURE test.exe: 0xC0000005: Access violation writing location 0x000000850F000DC0.

    and
    Exception thrown at 0x00007FFE859A8948 (GameAssembly.dll) in PURE test.exe: 0xC0000005: Access violation writing location 0x000000850F000DC0.


    What's confusing is that I'm not new to development on Hololens 2, I have developed multiple apps and deployed them successfully as late as November of last year. It seems that some sort of conversion from Unity to Hololens app has broken during this time gap.
    As a test, I removed any unnecessary components, created a scene with only a cube, and deployed it but the issue still persisted. The cause was the same error listed above (as well as a picture attached below).

    I will further look into this, and maybe try and download a previous Unity version where I could deploy the project. However it would be great if some people more knowledgeable than me look into this, it's frustrating to not be able to do work because of a minor error.

    Edit: I have reverted my Unity editor to 2021.3.16.f1 and the deployment operation no longer reports the error. This is extremely odd on Unity's end (especially since both versions are listed under LTS).
     

    Attached Files:

    Last edited: Apr 30, 2023
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,166
    Looks like you were running into https://issuetracker.unity3d.com/is...re-group-introduces-crash-when-hands-detected. It was a flaw in 1.5.0 version of the Input System package, and was fixed in 1.5.1.
     
  23. suhanabiswas309

    suhanabiswas309

    Joined:
    Apr 26, 2023
    Posts:
    5
    upload_2023-5-2_12-25-58.png


    Hi, can someone please help me with the above errors? I am deploying my Unity MRTK application to HoloLens2 using USB Device mode. The build had no errors, but after the app deployed to HoloLens, I see a loading animation constantly, and these errors in Visual Studio.
     
  24. DivinorWieldor

    DivinorWieldor

    Joined:
    Aug 24, 2021
    Posts:
    2
    You seem to be running into the same issue I was (which I found a solution to 2 posts above you). What is your Unity editor version?
    Switching to 2021.3.16f (or 2021.3.10f, have not tested for other versions) fixed it for me. If these are the same issues (which I assume so as they look like the same error message) then that should fix it.

    Unrelated to the above but a good thing to keep in mind: please try and read through previous posts, see what worked for who, check if it works for you, and if nothing works provide details in your help request. Your post provides very few details as to what the situation on your end may be.
     
  25. dreis_lspace

    dreis_lspace

    Joined:
    Feb 7, 2023
    Posts:
    1
    Am using Unity 2021.3.21f1 and this was happening to me as well. Upgrading the Input System package from 1.5.0 to v1.5.1 did the trick for me. Thanks @Tautvydas-Zilys !