Skip to content

Commit 579ff09

Browse files
Handle truncated XML frame info gracefully (#140)
When the XML frame has insufficient information, gracefully handle the case by returning the input as-is, instead of the earlier behavior of throwing an internal exception and failing.
1 parent eccf17a commit 579ff09

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Engine/ModuleInfoHelper.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ await Task.Run(() => Parallel.ForEach(listOfCallStacks, currItem => {
8383
using var sreader = new StringReader(line);
8484
using var reader = XmlReader.Create(sreader, new XmlReaderSettings() { XmlResolver = null });
8585
if (reader.Read()) {
86-
// seems to be XML; process attributes only if all 3 are there
86+
// seems to be XML; start reading attributes
8787
var moduleNameAttributeVal = reader.GetAttribute("module");
8888
if (string.IsNullOrEmpty(moduleNameAttributeVal)) moduleNameAttributeVal = reader.GetAttribute("name");
8989
var moduleName = Path.GetFileNameWithoutExtension(moduleNameAttributeVal);
@@ -96,15 +96,17 @@ await Task.Run(() => Parallel.ForEach(listOfCallStacks, currItem => {
9696
var pdbGuid = reader.GetAttribute("guid");
9797
var pdbAge = reader.GetAttribute("age");
9898
string uniqueModuleName;
99-
// createe a map of the last mapped module names to handle cases when the frame is "truncated" and the above PDB details are not available
99+
// Create a map of the last mapped module names to handle future cases when the frame is "truncated" and the above PDB details are not available
100100
if (pdbGuid != null && pdbAge != null) {
101+
// PDB GUID and age are valid
101102
uniqueModuleName = $"{pdbGuid.Replace("-", string.Empty).ToUpper()}{pdbAge}";
102103
if (latestMappedModuleNames.ContainsKey(moduleName)) latestMappedModuleNames[moduleName] = uniqueModuleName;
103104
else latestMappedModuleNames.Add(moduleName, uniqueModuleName);
104105
} else {
106+
// This frame / line is incomplete to the extent that we don't even have the PDB GUID and / or the PDB age - return the input as-is
105107
if (!latestMappedModuleNames.TryGetValue(moduleName, out uniqueModuleName)) {
106-
anyTaskFailed = true;
107-
return;
108+
outCallstack.AppendLine(line);
109+
continue;
108110
}
109111
}
110112
lock (syms) {

Tests/Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ private string PrepareLargeXEventInput() {
616616
// modify the input to not have any prior PDB info - this will be an "error" case
617617
input = "Frame = <frame id=\"02\" name=\"sqldk.dll\" address = \"0x100440609\"/>\r\n<frame id=\"03\" name=\"sqldk.dll\" address=\"0x10042249f\" />\n";
618618
ret = await csr.ResolveCallstacksAsync(await csr.GetListofCallStacksAsync(input, false, cts), pdbPath, false, null, false, true, false, true, false, false, null, cts);
619-
Assert.IsTrue(ret.StartsWith("Unable to determine symbol information from XML frames"));
619+
Assert.AreEqual("<frame id=\"02\" name=\"sqldk.dll\" address = \"0x100440609\"/>\r\n<frame id=\"03\" name=\"sqldk.dll\" address=\"0x10042249f\" />", ret.Trim());
620620
}
621621

622622
/// End-to-end test with XE histogram target and XML frames.

0 commit comments

Comments
 (0)