Skip to content

Commit ec2ea6f

Browse files
Fix exception in inline frame processing (#22)
1 parent d548ba5 commit ec2ea6f

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

Engine/DiaUtil.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ internal static string ProcessInlineFrames(string moduleName, bool useUndecorate
175175
}
176176
Marshal.ReleaseComObject(enumInlinees);
177177
} catch (COMException) {
178-
sbInline.AppendLine(" -- WARN: Unable to process inline frames");
178+
sbInline.AppendLine(" -- WARN: Unable to process inline frames; maybe symbols are mismatched?");
179+
} catch (System.ArgumentException) {
180+
sbInline.AppendLine(" -- WARN: Unable to process inline frames; maybe symbols are mismatched?");
179181
}
182+
180183
return sbInline.ToString();
181184
}
182185
}

GUI/MainForm.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
1111
using System.Net;
1212
using System.Globalization;
1313
using System.Configuration;
14-
using System.ComponentModel;
1514
using System.Threading.Tasks;
1615
using System.Threading;
1716

@@ -133,6 +132,14 @@ private void ResolveCallstacks_Click(object sender, EventArgs e) {
133132
this.MonitorBackgroundTask(backgroundTask);
134133

135134
finalOutput.Text = backgroundTask.Result;
135+
136+
if (backgroundTask.Result.Contains("-- WARN:")) {
137+
MessageBox.Show(this,
138+
"One or more potential issues exist in the output. This is sometimes due to mismatched symbols, so please double-check symbol paths and re-run if needed.",
139+
"Potential issues with the output",
140+
MessageBoxButtons.OK,
141+
MessageBoxIcon.Warning);
142+
}
136143
}
137144

138145
private void DisableCancelButton() {

Tests/Tests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void LargeXEventsInput() {
7575
xeventInput.AppendLine("</Events>");
7676
var timer = new System.Diagnostics.Stopwatch();
7777
timer.Start();
78-
var ret = csr.ResolveCallstacks(xeventInput.ToString(), @"..\..\..\Tests\TestCases\TestOrdinal", false, null, false, false, false, false, true, false, false, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
78+
csr.ResolveCallstacks(xeventInput.ToString(), @"..\..\..\Tests\TestCases\TestOrdinal", false, null, false, false, false, false, true, false, false, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
7979
timer.Stop();
8080
Assert.True(timer.Elapsed.TotalSeconds < 45 * 60); // 45 minutes max on GitHub hosted DSv2 runner (2 vCPU, 7 GiB RAM).
8181
}
@@ -401,6 +401,26 @@ public void InlineFrameResolution() {
401401
}
402402
}
403403

404+
/// "Fuzz" test for inline frame resolution by providing random offsets into the module. This test uses symbols for a Windows Driver Kit module, Wdf01000.sys, because private PDBs for that module are legitimately available on the
405+
/// Microsoft public symbols servers. https://github.com/microsoft/Windows-Driver-Frameworks/releases if interested.
406+
[Fact]
407+
[Trait("Category", "Unit")]
408+
public void RandomInlineFrameResolution() {
409+
using (var csr = new StackResolver()) {
410+
var pdbPath = @"..\..\..\Tests\TestCases\SourceInformation";
411+
var callstackInput = new System.Text.StringBuilder();
412+
// generate frames with random offsets
413+
var rng = new Random();
414+
// generate 1000 frames, each frame having a random offset into Wdf01000
415+
for (int frameNum = 0; frameNum < 1000; frameNum++) {
416+
callstackInput.AppendLine($"Wdf01000+{rng.Next(0, 1000000)}");
417+
}
418+
csr.ResolveCallstacks(callstackInput.ToString(), pdbPath, false, null, false, false, true, false, true, true, false, null);
419+
// We do not need to check anything; the criteria for the test passing is that the call did not throw an unhandled exception
420+
}
421+
}
422+
423+
404424
/// Test for inline frame resolution without source lines included This test uses symbols for a Windows Driver Kit module, Wdf01000.sys,
405425
/// because private PDBs for that module are legitimately available on the Microsoft public symbols servers. https://github.com/microsoft/Windows-Driver-Frameworks/releases if interested.
406426
[Fact][Trait("Category", "Unit")]

0 commit comments

Comments
 (0)