Skip to content

Conversation

@thaystg
Copy link
Member

@thaystg thaystg commented Jan 26, 2024

Backport of #97418 to release/8.0-staging

/cc @thaystg

Customer Impact

  • Customer reported
  • Found internally

dotnet/android#8653
Avoid assertion on runtime while debugging.
Fix debugger experience when it's trying to evaluate an expression that has a value type with an object inside it like this:

public struct EvaluateValueTypeWithObjectValueType
{
        private object myObject;
        double myDouble;
        public EvaluateValueTypeWithObjectValueType()
        {
            myObject = new int();
            myDouble = 10;
        }
}

Regression

  • Yes
  • No

This was introduced in this PR: #76332

Testing

Manually tested.
Also added a test case.

Risk

Medium risk, only reading the debugger buffer correctly.

@ghost ghost added the area-Debugger-mono label Jan 26, 2024
@thaystg thaystg added the Servicing-consider Issue for next servicing release review label Jan 26, 2024
@thaystg thaystg requested a review from lewing January 26, 2024 18:20
@ghost ghost assigned thaystg Jan 26, 2024
@ghost
Copy link

ghost commented Jan 26, 2024

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

Issue Details

null

Author: thaystg
Assignees: -
Labels:

area-Debugger-mono

Milestone: -

Comment on lines +93 to +96
for (int i = 0; i < arraySize; i++)
{
inlineArray.Add(await sdbAgent.ValueCreator.CreateFixedArrayElement(cmdReader, elementType, $"{i}", token));
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: this could probably be a method that takes in the type details, and the array size to return inlineArray, avoiding the multiple the awaits too.

}
else
{
cmdReader.BaseStream.Position-=sizeof(byte);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cmdReader.BaseStream.Position-=sizeof(byte);
cmdReader.BaseStream.Position -= sizeof(byte);

subtype: length.Rank == 1 ? "array" : null);
}

public async Task<JObject> CreateFixedArrayElement(MonoBinaryReader retDebuggerCmdReader, ElementType etype, string name, CancellationToken token)
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 very similar to ReadAsVariableValue. Maybe the core of that method can be extracted (to skip the reading from the retDebuggerCmdReader) - and that method can be used by ReadAsVariableValue and CreateFixedArrayElement.

ElementType etype = (ElementType)cmdReader.ReadByte();
if (etype == (ElementType)ValueTypeId.FixedArray && writableFields.Count() == 1)
{
ElementType elementType = (ElementType)cmdReader.ReadByte();
Copy link
Member

Choose a reason for hiding this comment

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

Which test type has this case?

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. we will take for consideration in 8.0.x

@rbhanda rbhanda added this to the 8.0.3 milestone Feb 1, 2024
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Feb 1, 2024
@lewing lewing merged commit ea2b2e8 into dotnet:release/8.0-staging Feb 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Debugger-mono Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants