Search Issue Tracker
Fixed in 2021.2.X
Votes
0
Found in
Issue ID
1323447
Regression
No
[Graphics] Possible to crash Unity with a stale/disposed GraphicsBuffer in a CommandBuffer
It is possible to crash Unity if you create a graphics CommandBuffer that references a GraphicsBuffer or a ComputeBuffer, dispose that graphics buffer, and later on try to execute the command buffer.
The gist of it is like:
var indexBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Index, 3, 2);
indexBuffer.SetData(new ushort[] {0, 1, 2});
var cmdBuffer = new CommandBuffer();
cmdBuffer.DrawProcedural(indexBuffer, Matrix4x4.identity, m_Material, 0, MeshTopology.Triangles, 3);
indexBuffer.Dispose();
// execute the command buffer that references an index buffer that is already disposed: crash
Graphics.ExecuteCommandBuffer(cmdBuffer);
cmdBuffer.Dispose();
This probably happens with most of the CommandBuffer commands that take a GraphicsBuffer or a ComputeBuffer argument.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Audio Mixer does not change volume when lowering volume on an Audio Mixer loaded from AssetBundles
- Error “Value cannot be null. Parameter name: key UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)” thrown and Addressables build fails when "Include in Build" is disabled and using Addressables For Android package
- “error CS0433: The type 'CodeBinaryOperatorType' exists in both 'System.CodeDom and 'System" compilation errors are thrown when opening a specific project
- Metal Vertex Shader warning is being thrown when creating a VR Template Project
- Asset database warning is thrown when declaring font variable in the USS text file
Add comment