{"record":{"id":"376f426a7da368a4","repo":"stride3d/stride","slug":"count","errorCode":null,"errorMessage":"count","messagePattern":"count","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/GraphicsDevice.Vulkan.cs","lineNumber":306,"sourceCode":"\n        /// <summary>\n        /// Executes a deferred command list.\n        /// </summary>\n        /// <param name=\"commandList\">The deferred command list.</param>\n        public void ExecuteCommandList(CompiledCommandList commandList)\n        {\n            ExecuteCommandListInternal(commandList);\n        }\n\n        /// <summary>\n        /// Executes multiple deferred command lists.\n        /// </summary>\n        /// <param name=\"count\">Number of command lists to execute.</param>\n        /// <param name=\"commandLists\">The deferred command lists.</param>\n        public unsafe void ExecuteCommandLists(int count, CompiledCommandList[] commandLists)\n        {\n            if (commandLists == null) throw new ArgumentNullException(nameof(commandLists));\n            if (count > commandLists.Length) throw new ArgumentOutOfRangeException(nameof(count));\n\n            var commandBufferInfos = stackalloc VkCommandBufferSubmitInfo[count];\n            for (int i = 0; i < count; i++)\n                commandBufferInfos[i] = CommandBufferSubmit(commandLists[i].NativeCommandBuffer);\n\n            ulong nextCommandListFenceValue;\n            lock (QueueLock)\n            {\n                var commandListFenceValue = CommandListFence.NextFenceValue++;\n                nextCommandListFenceValue = commandListFenceValue + 1;\n                // Make sure all copies are done as well\n                var copyFenceValue = CopyFence.NextFenceValue;\n\n                var waitInfos = stackalloc VkSemaphoreSubmitInfo[]\n                {\n                    SemaphoreSubmit(CommandListFence.Semaphore, commandListFenceValue),\n                    SemaphoreSubmit(CopyFence.Semaphore, copyFenceValue),\n                };","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/GraphicsDevice.Vulkan.cs#L288-L324","documentation":"Argument-null validation on the count parameter of GraphicsDevice.ExecuteCommandLists: the number of command lists to execute is null/negative. The unsafe execution loop iterates count times over the commandLists array, so a bad count would read out of bounds; the method rejects it up front, as declared in its documentation.","triggerScenarios":"Calling ExecuteCommandLists with count > commandLists.Length, e.g. after filtering the array without updating the count.","commonSituations":"Code that trims or reuses a shared array but keeps a stale count; off-by-one errors when batching command lists; copy-pasted submit code where the count came from a different collection.","solutions":["Pass count equal to (or less than) the actual array length","Derive count from the array (commandLists.Length) instead of a separate variable","Assert the invariant count <= commandLists.Length in your render loop before submitting"],"exampleFix":"// before\nGraphicsDevice.ExecuteCommandLists(5, lists); // lists.Length == 3\n// after\nGraphicsDevice.ExecuteCommandLists(lists.Length, lists);","handlingStrategy":"validation","validationCode":"count = Math.Min(count, commandLists?.Length ?? 0);\nGraphicsDevice.ExecuteCommandLists(count, commandLists);","typeGuard":null,"tryCatchPattern":"try\n{\n    GraphicsDevice.ExecuteCommandLists(count, commandLists);\n}\ncatch (ArgumentOutOfRangeException ex)\n{\n    Logger.Error(ex, $\"count={count} exceeds commandLists.Length={commandLists.Length}\");\n}","preventionTips":["Derive count from commandLists.Length instead of parallel bookkeeping","Use a single source of truth for the batch of command lists","Add debug asserts for count <= array length in your submit helper"],"tags":["argument-out-of-range","vulkan","command-list"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}