GameAssembly.dll Access violation reading location ....

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 var array = e.imageArray;, I don't get any exception).

     void OneFrameAvailable(object sender, RMFrameData e){
         var height = e.height;
         var width = e.width;
         var array = e.imageArray;

         Enqueue(() => {
         if (tex == null)
                         tex = new Texture2D(width, height, TextureFormat.BGRA32, false);
                         material.mainTexture = tex;

I've attached screenshots of call stack and breakpoint of where the exception is been thrown.

Can you show the implementation of RMFrameData? A crash inside the garbage collector usually means memory corruption.

Completely newbie in C++ and trying to write the WRC.


runtimeclass RMFrameData
        BYTE[] imageArray;


struct FrameData : FrameData <RMFrameData>
   RMFrameData() = default;

   com_array<uint8_t>& imageArray();
   void imageArray(array_view<uint8_t const> value);

   com_array<uint8_t> m_imageArray{};


com_array<uint8_t>& RMFrameData::imageArray()
   return m_imageArray;
void RMFrameData::imageArray(array_view<uint8_t const> value)
   m_imageArray = winrt::com_array<BYTE>(std::move_iterator(value.begin()), std::move_iterator(value.end()));

Method sending RMFrameData

void PVProcessor::OnFrameArrived(const MediaFrameReader& sender, const MediaFrameArrivedEventArgs& args)

       if (MediaFrameReference frame = sender.TryAcquireLatestFrame())
           auto frame_data = winrt::make_self<winrt::HL2CV_WRT::implementation::RMFrameData>();

           if (frame != nullptr && frame.VideoMediaFrame() != nullptr) {

               uint32_t pixelBufferDataLength = 0;
               uint8_t* pixelBufferData;
               SoftwareBitmap bitmap = SoftwareBitmap::Convert(frame.VideoMediaFrame().SoftwareBitmap(), BitmapPixelFormat::Bgra8);
               if (bitmap != nullptr) {
                   BitmapBuffer bitmapBuffer = bitmap.LockBuffer(BitmapBufferAccessMode::Read);

                   auto spMemoryBufferByteAccess{ bitmapBuffer.CreateReference().as<::Windows::Foundation::IMemoryBufferByteAccess>() };
                   winrt::check_hresult(spMemoryBufferByteAccess->GetBuffer(&pixelBufferData, &pixelBufferDataLength));

                   std::vector<BYTE> pixelVectorData{};
                   pixelVectorData.insert(pixelVectorData.end(), std::make_move_iterator(pixelBufferData), std::make_move_iterator(pixelBufferData + pixelBufferDataLength));
                   frame_data->imageArray(pixelVectorData); //set com_array here.

           m_frame_data_available(*this, *frame_data);

Sorry, I don't know how to format it in C++. Thanks for your help.

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):

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:

appverif -disable * -for Game.exe

Thanks for your quick reply. But it does not look like HoloLens can run application verifier or am I missing something?

Oh, can you not reproduce it on PC?

No, the windows runtime component is using the sensors available on HoloLens 2. Thank you so much for your help.

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.

hi, I'm running into the same issue too. how did you solve this issue?

What exactly are you running into?

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.


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.

Do you have a callstack? Could it be an infinite recursion problem in your code?

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:

This error is not from my code. This appears to be a Unity Script causing this. Unity.InputSystem.InputControl

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.

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"?

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:

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.

Commenting out that "Headers = value;" line should fix it. It doesn't look like the getter is trying to retrieve a saved value anyway.

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."

Can you report a bug on this?

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.8937378--1225671--Bug found 10042023.png