Skip to content

fix: Avoid reading unmapped memory in FastTextRenderer - #3376

Merged
xen2 merged 2 commits into
stride3d:masterfrom
BenjaBobs:fix/fast-text-renderer-vulkan-unmap
Sep 9, 2026
Merged

fix: Avoid reading unmapped memory in FastTextRenderer#3376
xen2 merged 2 commits into
stride3d:masterfrom
BenjaBobs:fix/fast-text-renderer-vulkan-unmap

Conversation

@BenjaBobs

Copy link
Copy Markdown
Contributor

PR Details

FastTextRenderer.Initialize retained a pointer to mapped index-buffer memory and passed it to Buffer.Index.New after unmapping the buffer.
On Linux/Vulkan the pointer was no longer valid, which caused an AccessViolationException when Buffer.Index.New tried to copy the index data.
This change builds the indices in a managed int[] and passes that array directly to Buffer.Index.New.
This also removes the temporary graphics buffer and the now-unnecessary unsafe modifier.
I rebuilt the local Stride packages and confirmed that a code-only game using Vulkan can render debug text without crashing.

Related Issue

Fixes #3375

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

I tested the change in a code-only game on Linux/Vulkan.
I did not run Game Studio because it is not currently available on Linux.

@BenjaBobs

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

Comment thread sources/engine/Stride.Graphics/FastTextRenderer.cs
Comment thread sources/engine/Stride.Graphics/FastTextRenderer.cs Outdated
Vulkan says unmapped memory is no longer readable
@BenjaBobs
BenjaBobs force-pushed the fix/fast-text-renderer-vulkan-unmap branch from 8090d6d to d493806 Compare September 5, 2026 12:39
Comment thread sources/engine/Stride.Graphics/FastTextRenderer.cs Outdated
Comment thread sources/engine/Stride.Graphics/FastTextRenderer.cs
…eates new ones

End() re-initializes when the character count grows, which overwrote the index
buffer, the vertex buffers and the effect instance without disposing them.
Also removes IndexStride, unused since the indices moved to a managed array.
@xen2
xen2 force-pushed the fix/fast-text-renderer-vulkan-unmap branch from 6388b3a to 3a0d448 Compare September 8, 2026 05:48
@xen2
xen2 merged commit cc08fce into stride3d:master Sep 9, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastTextRenderer reads a Vulkan mapping after it has been unmapped

4 participants