Search Unity

Crash: "Graphics.DrawProceduralIndirect with invalid buffer"

Discussion in 'General Graphics' started by thimler9, Apr 14, 2021.

  1. thimler9

    thimler9

    Joined:
    Sep 25, 2019
    Posts:
    10
    I'm working on a procedural terrain generation system that uses the Graphics.DrawProceduralIndirect function to draw it. The drawing looks perfectly fine, but very occasionally, only when it's built, do I get the error "Graphics.DrawProceduralIndirect with invalid buffer". After a bunch of these, the game usually crashes. I'm using URP as well.

    This is one of the crash logs:

    PlayerConnection initialized from C:/Users/Tom/Documents/URPVoxel Builds/Test/Voxel Terrain URP_Data (debug = 0)
    PlayerConnection initialized network socket : 0.0.0.0 55400
    Multi-casting "[IP] 10.0.0.52 [Port] 55400 [Flags] 2 [Guid] 2321555746 [EditorId] 2146956991 [Version] 1048832 [Id] WindowsPlayer(DESKTOP-U5L5AVC) [Debug] 0 [PackageName] WindowsPlayer [ProjectName] Voxel Terrain URP" to [225.0.0.222:54997]...
    Started listening to [0.0.0.0:55400]
    PlayerConnection already initialized - listening to [0.0.0.0:55400]
    Initialize engine version: 2020.2.1f1 (270dd8c3da1c)
    [Subsystems] Discovering subsystems at path C:/Users/Tom/Documents/URPVoxel Builds/Test/Voxel Terrain URP_Data/UnitySubsystems
    GfxDevice: creating device client; threaded=1
    Direct3D:
    Version: Direct3D 11.0 [level 11.1]
    Renderer: NVIDIA GeForce RTX 3070 (ID=0x2484)
    Vendor: (null)
    VRAM: 3072 MB
    Driver: 27.21.14.6192
    D3D11 device created for Microsoft Media Foundation video decoding.
    <RI> Initializing input.

    <RI> Input initialized.

    <RI> Initialized touch support.

    UnloadTime: 0.314000 ms
    Graphics.DrawProceduralIndirect with invalid buffer

    ...
    ... There's more than 50 of these
    ...

    Graphics.DrawProceduralIndirect with invalid buffer

    Graphics.DrawProceduralIndirect with invalid buffer

    Graphics.DrawProceduralIndirect with invalid buffer

    Graphics.DrawProceduralIndirect with invalid buffer

    Graphics.DrawProceduralIndirect with invalid buffer

    Graphics.DrawProceduralIndirect with invalid buffer

    Crash!!!
    SymInit: Symbol-SearchPath: '.;C:\Users\Tom\Documents\URPVoxel Builds\Test;C:\Users\Tom\Documents\URPVoxel Builds\Test;C:\Windows;C:\Windows\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 534, UserName: 'Tom'
    OS-Version: 10.0.0

    ========== OUTPUTTING STACK TRACE ==================

    0x79BFF986 (UnityPlayer) UnityMain
    0x79A2A62D (UnityPlayer) UnityMain
    0x79A2412C (UnityPlayer) UnityMain
    0x79C99BF6 (UnityPlayer) UnityMain
    0x79C9A46E (UnityPlayer) UnityMain
    ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 79892B9C)
    0x79892B9C (UnityPlayer) (function-name not available)
    0x79CA8466 (UnityPlayer) UnityMain
    0x79CA9684 (UnityPlayer) UnityMain
    0x79CADBA2 (UnityPlayer) UnityMain
    0x79F9A6BA (UnityPlayer) UnityMain
    0x7647FA29 (KERNEL32) BaseThreadInitThunk
    0x77597C7E (ntdll) RtlGetAppContainerNamedObjectPath
    0x77597C4E (ntdll) RtlGetAppContainerNamedObjectPath

    ========== END OF STACKTRACE ===========


    Does "invalid buffer" mean that the draw arguments buffer is invalid, the triangles buffer needed for the draw is invalid, or could it be both? Looking at the stack trace, it looks like I'm accessing some memory address that I don't have access to, but I'm stumped on what is causing that.

    I know this isn't a lot of information to go off of, but if I could get a better explanation of what the "invalid buffer" is that would be great.
     
  2. pelaezjorge

    pelaezjorge

    Joined:
    Aug 3, 2020
    Posts:
    8
    I'm having a similar problem, where the buffer is only occasionally invalid and causes the application to crash.
    Did you find any possible cause for it?
     
  3. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    731
    Unity will free memory from buffers (thus invalidating) when you are in the editor and switch programs. Also make sure you aren't running out of vram or something silly like that.
     
  4. pelaezjorge

    pelaezjorge

    Joined:
    Aug 3, 2020
    Posts:
    8
    This happens both in Editor and built versions, and not switching programs. All the memory is allocated at Start() and released at OnDestroy(), and there is plenty left.
     
  5. pmurph03

    pmurph03

    Joined:
    Mar 17, 2014
    Posts:
    54
    I'm getting a similar problem in the game I'm working on in 2d urp, with 2021.3.16. Was originally on 2021.3.9 using d3d11 and upgraded after a bug report was listed as fixed and several graphics mentions in the changelogs for the versions that i thought might be related. But it didn't solve my invalid buffer issue. The crash is inconsistent so I couldn't reproduce it and create a minimal project to submit as a bug report.

    I tried using windbg and a force full crash dump but that didn't provide me any usable information that I could find to fix something on my end.

    For now I've changed the graphics api to default to Vulkan, which hasn't crashed yet, but it wasn't consistent for me to begin with so I could just be getting lucky. Just posting this here as it's the first result for the error and this was the solution that I've found has worked.
    edit: been a week of testing and still no crashes on vulkan
    edit2: still no crashes, an occasional error of vulkan trying to draw with missing bindings, but this doesn't crash unity and has no effect on functionality.
     
    Last edited: Jan 25, 2023