The thread tried to read from or write to a virtual address for which it does not have the appropria

Hello,

since 2022.3.f22 (coming from 2022.3.f20) I had several crashes in my game. The crashes are a bit random and happen after a while (sometimes after 30 mins in game). I am not 100% sure if it is related to the unity version, but before the upgrade I never had these crashes.

Here are some info (log):

========== OUTPUTTING STACK TRACE ==================
0x00007FF7167133CB (Unity) GfxDeviceD3D12Base::smile:rawBuffersCommon
0x00007FF71671266E (Unity) GfxDeviceD3D12Base::smile:rawBufferRanges
0x00007FF7167128F0 (Unity) GfxDeviceD3D12Base::smile:rawBuffers
0x00007FF717D51852 (Unity) GfxDeviceWorker::RunCommand
0x00007FF717D545DB (Unity) GfxDeviceWorker::RunExt
0x00007FF717D546F8 (Unity) GfxDeviceWorker::RunGfxDeviceWorker
0x00007FF71638E166 (Unity) Thread::RunThreadWrapper
0x00007FF9C2F3257D (KERNEL32) BaseThreadInitThunk
0x00007FF9C3B6AA58 (ntdll) RtlUserThreadStart

Crash.dmp says:
The thread tried to read from or write to a virtual address for which it does not have the appropriate access.

I have attached the log and dmp file.

If anyone has an idea what the reason could be, I would be very thankful. Because I have no idea where to start searching or what to do :frowning:

9735511–1392229–Crash_2024-03-28_171038014.zip (857 KB)

When you get a crash, you need to read the log higher up. The lines before “Crash!!!” are most interesting, and they point at the GPU failing to create a small buffer (despite enough free memory):

d3d12: swapchain present failed (887a0005).
d3d12: swapchain present failed (887a0005).
Device removed reason (887a0006).
GfxDevice was not out of Local memory
Local memory usage:
Budget: 16024338432
CurrentUsage: 5574795264
AvailableForReservation: 67108864
CurrentReservation: 8146386944
GfxDevice was not out of Non-Local memory
Non-Local memory usage:
Budget: 15917125632
CurrentUsage: 552783872
AvailableForReservation: 0
CurrentReservation: 8092780544
Set -force-d3d12-debug for more information on device removal
d3d12: swapchain present failed (887a0005).
d3d12: swapchain present failed (887a0005).
Device removed reason (887a0006).
GfxDevice was not out of Local memory
Local memory usage:
Budget: 16024338432
CurrentUsage: 5574795264
AvailableForReservation: 67108864
CurrentReservation: 8146386944
GfxDevice was not out of Non-Local memory
Non-Local memory usage:
Budget: 15917125632
CurrentUsage: 552783872
AvailableForReservation: 0
CurrentReservation: 8092780544
Set -force-d3d12-debug for more information on device removal
d3d12 : CreateCommittedResource 'BufferD3D12::CreateBufferResource() Buffer' (480 x 1) format 0 failed (887a0005).
    Device Remove Reason (HRESULT): 0x887a0006
    Device Memory Stats:
        Local AvailableForReservation: 7769 MB, Budget: 15282 MB, CurrentUsage: 5316 MB, CurrentReservation: 64 MB
        Non-local AvailableForReservation: 7717 MB, Budget: 15179 MB, CurrentUsage: 527 MB, CurrentReservation: 0 MB
d3d12: CreateResource for buffer failed.
d3d12: failed to create a buffer of size 480
d3d12 : CreateCommittedResource 'BufferD3D12::CreateBufferResource() Buffer' (60 x 1) format 0 failed (887a0005).
    Device Remove Reason (HRESULT): 0x887a0006
    Device Memory Stats:
        Local AvailableForReservation: 7769 MB, Budget: 15282 MB, CurrentUsage: 5316 MB, CurrentReservation: 64 MB
        Non-local AvailableForReservation: 7717 MB, Budget: 15179 MB, CurrentUsage: 527 MB, CurrentReservation: 0 MB
d3d12: CreateResource for buffer failed.
d3d12: failed to create a buffer of size 60
BufferD3D12 : Unexpected null accessor on Buffer
Crash!!!

Earlier in the log it mentioned that the GPU Profiler is enabled. This may use some memory too. You may want to disable profiling (and development mode too) in the build settings if you aren’t profiling.

Then there’s always a possibility that something causes the GPU to “reset”, like a screen resolution change or entering standby. Sometimes this can be caused by faulty connectors or cables. I once had one that blinked the screen black for a split second every now and then, sometimes disrupting my window layout due to the momentary res change.

Other than that, perhaps try a gfx driver update. And if you don’t rely on D3D12 features, make D3D11 the default which is likely more stable and compatible. D3D12 has left experimental not too long ago after having been experimental over … way too many years. I still don’t trust it. :wink:

Thank you very much for your answer! I will try that out immediately.

I must admit, that even after you have extracted the important part of the log, it is hard for me to find where it points me to “out of memory”. Can you maybe tell me which line I have to look for?
I only see “GfxDevice was not out of Non-Local memory” and “GfxDevice was not out of Local memory”.

It’s this:

  • d3d12: CreateResource for buffer failed.
  • d3d12: failed to create a buffer of size 480

And another buffer, followed by null access on buffer (since it failed to create it is null).

I should have omitted most of the above. Initially I read it as “out of memory” but there was a “not” in there that I overlooked at first.

So it is not out of memory issue? Because I have a 4080 and my game is not very GPU heavy. Task Manager shows 6.6 from 16 GB in use actually. Testing with new drivers now…

Edit: Since new GPU drivers I had no more crashes… very strange.

Meh… it still crashes.
After new drivers I tried to switch t DX11 and now another exception dialog, but no crash folder is created. I attached the DX11 message.

Because this kind of bug never happend in unity version 2022.3.f20 I guess this is related to some changes in unity. I didnt changed much since the upgrade… at least not graphics related. Sure I am not 100% certain that this bug wasnt present before, but I didnt noticed it at all and now it happens quite often.

9737524--1392778--bug_dx11_unity.png

Update: Very strange. I tested with 2 applications parallel… one in editor and one the built version. When one version crashes, the other one crashes too.

I can not create a bug report because whenever I click on upload files, the progress does not start and I have to cancel.

Anyone can help?

Same exception randomly just using the Unity 2022.3.35f1 LTS Editor. “The thread tried to read from or write to a virtual address for which it does not have the appropriate access.” This crash happens randomly and is occurring on three different workstations, one of them a laptop. So I am unsure if this is directly tied to user’s hardware specs/setup.

I’ve noticed another reporting a potential link → “I got the identical message when opening a project using Unity Pro. After a tedious and lengthy process of elimination, the problem was isolated to the “Do not keep history of recently opened documents” policy being enabled.”

1 Like

Thank you for posting. This worked for me… but WHY did it work? :slight_smile: