Skip to content

Conversation

VSadov
Copy link
Member

@VSadov VSadov commented Oct 14, 2025

sprintf_s pops a crt assert dialog in checked/debug if the buffer is too short.
_snprintf_s with _TRUNCATE does not have such problem.

We may see some pretty long names here.

An example that was triggering the assert in #119432 was:
System.Collections.Generic.IAsyncEnumerator<System.ValueTuple<Microsoft.CodeAnalysis.Project,System.Collections.Immutable.ImmutableArray<System.ValueTuple<Microsoft.CodeAnalysis.ISymbol,Microsoft.CodeAnalysis.FindSymbols.SymbolGroup>>>>.MoveNextAsync

@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 15:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a CRT assert dialog issue in debug/checked builds when creating async resumption stub names. The change replaces sprintf_s with _snprintf_s using the _TRUNCATE option to handle cases where method names are too long for the fixed-size buffer.

Key changes:

  • Switches from sprintf_s to _snprintf_s with _TRUNCATE flag to prevent CRT assertion dialogs
  • Maintains the same buffer size and error checking logic

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@VSadov VSadov enabled auto-merge (squash) October 15, 2025 15:42
@VSadov
Copy link
Member Author

VSadov commented Oct 15, 2025

/ba-g the failures are all #120577

@VSadov VSadov merged commit bc12cc3 into dotnet:main Oct 15, 2025
95 of 97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants