Skip to content

Commit

Permalink
Fix string issue with minidumps
Browse files Browse the repository at this point in the history
In minidumps we had an issue where string offset fields would be found
but they could not actually get values.
  • Loading branch information
leculver committed Sep 24, 2015
1 parent c15af5a commit dee3908
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Microsoft.Diagnostics.Runtime/Desktop/heap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,23 @@ public override IEnumerable<ClrRoot> EnumerateRoots(bool enumerateStatics)
yield return root;
}


internal string GetStringContents(Address strAddr)
{
if (strAddr == 0)
return null;

if (_firstChar == null || _stringLength == null)
if (!_initializedStringFields)
{
_firstChar = StringType.GetFieldByName("m_firstChar");
_stringLength = StringType.GetFieldByName("m_stringLength");

if (_firstChar.Type == null)
_firstChar = null;

if (_stringLength.Type == null)
_stringLength = null;

_initializedStringFields = true;
//Debug.Assert(m_firstChar != null && m_stringLength != null);
//Debug.Assert(m_firstChar == null || m_firstChar.Offset + IntPtr.Size == m_runtime.GetStringFirstCharOffset());
//Debug.Assert(m_stringLength == null || m_stringLength.Offset + IntPtr.Size == m_runtime.GetStringLengthOffset());
Expand Down Expand Up @@ -881,6 +887,7 @@ internal ClrElementType GetElementType(BaseDesktopHeapType type, int depth)

private Dictionary<ModuleEntry, int> _typeEntry = new Dictionary<ModuleEntry, int>(new ModuleEntryCompare());
private ClrInstanceField _firstChar, _stringLength;
bool _initializedStringFields = false;
private LastObjectData _lastObjData;
private LastObjectType _lastObjType;
private ClrType[] _basicTypes;
Expand Down

2 comments on commit dee3908

@rupreetg
Copy link

Choose a reason for hiding this comment

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

I am debugging a minidump using CLRMD and I am getting _firstChar null. This causes to break the if condition and we get a Object null reference exception -
if(_firstChar.Type == null)

In what scenario is _firstChar null and should we be handling the scenario here?

I ran the minidump using other tools and it was able to analyze it properly.

@rupreetg
Copy link

Choose a reason for hiding this comment

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

I've raised an issue for the same - #37

Please sign in to comment.