{"record":{"id":"017a9b55645c4972","repo":"stride3d/stride","slug":"invalid-state-for-resource-commandlistfencevalue-commandlist","errorCode":null,"errorMessage":"Invalid state for {resource.CommandListFenceValue}","messagePattern":"Invalid state for (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/CommandList.Vulkan.cs","lineNumber":1602,"sourceCode":"                    // updated in a previous command list which hasn't be finished yet\n                    || (resource.CommandListFenceValue is not null && !GraphicsDevice.CommandListFence.IsFenceCompleteInternal(resource.CommandListFenceValue.Value)))\n                {\n                    // User told us not to wait, return right away\n                    if (doNotWait)\n                    {\n                        return new MappedResource(resource, subResourceIndex, dataBox: default);\n                    }\n\n                    if (resource.UpdatingCommandList == this)\n                        // Need to flush? (check if part of current command list)\n                        // resource.CommandListFenceValue should be set after\n                        FlushInternal(false);\n                    else if (resource.UpdatingCommandList is not null)\n                        // Another command list updated this resource, but it's not been submitted (otherwise it would be stored in resource.CommandListFenceValue\n                        throw new InvalidOperationException(\"CommandList updating the staging resource has not been submitted\");\n\n                    if (resource.CommandListFenceValue is null)\n                        throw new InvalidOperationException($\"Invalid state for {resource.CommandListFenceValue}\");\n\n                    GraphicsDevice.CommandListFence.WaitForFenceCPUInternal(resource.CommandListFenceValue.Value);\n\n                    // We're now up to date, remove command list fence value (if any)\n                    resource.CommandListFenceValue = null;\n                }\n            }\n\n            // Also make sure all copy queues are done\n            // (important for all cases, since it uploads initial data and also set resource barrier)\n            if (resource.CopyFenceValue.HasValue)\n            {\n                GraphicsDevice.CopyFence.WaitForFenceCPUInternal(resource.CopyFenceValue.Value);\n                resource.CopyFenceValue = null;\n            }\n\n            void* mappedMemory;\n            GraphicsDevice.NativeDeviceApi.vkMapMemory(GraphicsDevice.NativeDevice, resource.NativeMemory, (ulong) offsetInBytes, (ulong) lengthInBytes, VkMemoryMapFlags.None, &mappedMemory);","sourceCodeStart":1584,"sourceCodeEnd":1620,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/CommandList.Vulkan.cs#L1584-L1620","documentation":"After resolving the updating command list, mapping a Staging resource requires a recorded CommandListFenceValue to wait on. If it is null, Stride's internal state is inconsistent (no fence value was recorded for the resource) and it throws InvalidOperationException including the null value in the message.","triggerScenarios":"Mapping a Staging resource whose CommandListFenceValue was never set because the update path did not record a fence value (internal state bug or resource updated before the device fence was established).","commonSituations":"Engine-internal invariant breakage when mixing low-level resource updates with custom command list management; hitting the message with 'Invalid state for ' (empty) because the value is null.","solutions":["Ensure staging resources are only updated through standard APIs (SetData/GetData) so fence values are recorded","Check for Stride version regressions around staging mapping and update to a fixed release","Avoid manually resetting/clearing resource.UpdatingCommandList or CommandListFenceValue state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { cmdList.MapSubResource(staging, 0, MapMode.Read); } catch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Invalid state for\")) { /* treat as engine bug: recreate staging resource or file an issue */ }","preventionTips":["Update staging resources only via standard SetData/GetData APIs","Do not manually mutate resource.UpdatingCommandList / CommandListFenceValue","Keep Stride up to date; report occurrences with a reproduction"],"tags":["vulkan","staging-resource","internal-state"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}