Bug in dumpobjRegex throws error with Get-DbgObject


While trying to use Get-DbgObject with recent dumps from .Net v4 taken on WinServer 2008, I hit a number of situations on which Get-DbgObject throws an exception while parsing the return from its "!do" equivalent call. I tracked this to a regex call in "Parse-DumpObject" at line 1527 in the current packaged download. The line sequence reads as follows where the actual exception is thrown on line 1530 based on the parsing of the contents of $line:
            # Parse a line using regex
            $match = $dumpobjRegex.Match($line)
            if(-not ($match.Success)){
                Write-Verbose "Failing line $line"
                throw "Regex failing on '$line'"
In my case, the raw call for my target object address returned a '+' sign in the truncated class type column.
          MT    Field   Offset                 Type VT     Attr            Value Name
000007fef8a2d440 4000072 4c System.Boolean 1 instance 0 aborted
000007fef8a2d440 4000073 4d System.boolean 1 instance 0 closeCalled
000007fef0af3608 4000074 8 ...ct+ExceptionQueue 0 instance 0000000000000000 exceptionQueue
The fix I came up with is to edit the declaration for $dumpobjRegex made just prior in the code to the ParseDumpObject function. (This is at line 1446 in the latest full download) and add the "+" sign to the allowable content values for that column.
So the line there from the current release that reads:
\s+(?<Type>[ .\w,-_[]`]{0,24})? # Type is 20 chars, 4 extra w/sp in .net 4, optional
\s+(?<Type>[ .+\w,-_[]`]{0,24})? # Type is 20 chars, 4 extra w/sp in .net 4, optional
This resolved this particular problem with Get-DbgObject.


BRiddle wrote Jul 12, 2012 at 8:25 PM

This is the same issue, but differs from the fix provided in the issue titled "Get-DbgObject fails on a "Socket". The workaround provided in that the fix from that issue had added the plus sign without the escape symbol.

I may be wrong, but from my read of the PowerShell documentation, putting the '+' sign without the escape I used in my "+" addition does not mean add the plus to the allowable list of characters/sequences; but instead means that the regex should match "repeating instances of the specified pattern". So "\w+" means match repeating patterns of "\w" rather than to allow the plus sign as an escaped, literal character within that match set.

wrote Feb 14, 2013 at 2:30 AM