{"record":{"id":"57b7a076539172bb","repo":"stride3d/stride","slug":"resource-commandlist-vulkan","errorCode":null,"errorMessage":"resource","messagePattern":"resource","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Vulkan/CommandList.Vulkan.cs","lineNumber":1547,"sourceCode":"                }\n            }\n        }\n\n        // TODO GRAPHICS REFACTOR what should we do with this?\n\n        /// <summary>\n        /// Maps a subresource.\n        /// </summary>\n        /// <param name=\"resource\">The resource.</param>\n        /// <param name=\"subResourceIndex\">Index of the sub resource.</param>\n        /// <param name=\"mapMode\">The map mode.</param>\n        /// <param name=\"doNotWait\">if set to <c>true</c> this method will return immediately if the resource is still being used by the GPU for writing. Default is false</param>\n        /// <param name=\"offsetInBytes\">The offset information in bytes.</param>\n        /// <param name=\"lengthInBytes\">The length information in bytes.</param>\n        /// <returns>Pointer to the sub resource to map.</returns>\n        public unsafe partial MappedResource MapSubResource(GraphicsResource resource, int subResourceIndex, MapMode mapMode, bool doNotWait = false, int offsetInBytes = 0, int lengthInBytes = 0)\n        {\n            if (resource == null) throw new ArgumentNullException(\"resource\");\n\n            var rowPitch = 0;\n            var usage = GraphicsResourceUsage.Default;\n\n            if (resource is Texture texture)\n            {\n                usage = texture.Usage;\n                if (lengthInBytes == 0)\n                    lengthInBytes = texture.ComputeSubResourceSize(subResourceIndex);\n                rowPitch = texture.ComputeRowPitch(subResourceIndex % texture.MipLevelCount);\n\n                offsetInBytes += texture.ComputeBufferOffset(subResourceIndex, depthSlice: 0);\n            }\n            else\n            {\n                if (resource is Buffer buffer)\n                {\n                    usage = buffer.Usage;","sourceCodeStart":1529,"sourceCodeEnd":1565,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Vulkan/CommandList.Vulkan.cs#L1529-L1565","documentation":"Argument-null validation on the resource parameter of CommandList's subresource Map method (Vulkan backend). Mapping a subresource requires a valid GPU resource; a null resource has no Vulkan memory to map, so the method throws ArgumentNullException named 'resource', as declared in its documentation.","triggerScenarios":"Calling CommandList.MapSubResource(null, ...) with a texture/buffer variable that was never assigned or was disposed and cleared to null.","commonSituations":"Deferred initialization where the resource creation call failed silently; disposed resource set to null; typo assigning to a local instead of the field.","solutions":["Ensure the Texture/Buffer was successfully created before mapping","Check resource creation return values and dispose logic that may null the field","Guard the call with a null check and log/early-return instead of reaching the API"],"exampleFix":"// before\ncmdList.MapSubResource(texture, 0, MapMode.Write);\n// after\nif (texture == null) throw new InvalidOperationException(\"texture not initialized\");\ncmdList.MapSubResource(texture, 0, MapMode.Write);","handlingStrategy":"validation","validationCode":"if (resource == null) return; // or log and bail before calling MapSubResource","typeGuard":"if (resource is Texture t) { /* safe to map */ } else if (resource is Buffer b) { /* safe to map */ }","tryCatchPattern":"try { var mapped = cmdList.MapSubResource(res, 0, MapMode.Write); } catch (ArgumentNullException) { /* resource was null; initialize it */ }","preventionTips":["Validate resource fields right after creation","Avoid nulling disposed resources if they may still be mapped later","Wrap resource creation and mapping in the same initialization scope"],"tags":["null-argument","mapping","vulkan"],"backgroundTag":"null-argument","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"}