Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely create VirtualCharSequence from string in StackFrameParser #59283

Closed
wants to merge 18 commits into from

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Feb 4, 2022

Fixes #59258

@ryzngard ryzngard requested a review from a team as a code owner February 4, 2022 19:03
/// <returns></returns>
public static VirtualChar CreateNextInString(string text, int index, Func<int, int, TextSpan> createSpan, out int consumedCharacters)
{
if (Rune.TryCreate(text[index], out var rune))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ported from AbstractVirtualCharService.cs

@ryzngard
Copy link
Contributor Author

ryzngard commented Feb 8, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@ryzngard
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@JoeRobich
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

Comment on lines 180 to 181

index += ConvertTextAtIndexToRune(tokenText, index, result, offset);
Copy link
Member

Choose a reason for hiding this comment

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

This seems to already be handled by the else clause that you added. By having it here this code is executing twice and some of the text is not covered by the earlier quote and brace checks.

Suggested change
index += ConvertTextAtIndexToRune(tokenText, index, result, offset);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not entirely sure I follow. If we move the characters by a certain amount the index will always need to be added to. CreateNextInString will consume some number of characters to produce a virtualChar. That's separate from ConvertTextAtIndexToRune

@ryzngard ryzngard closed this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assertion in StackFrameParser
4 participants