Skip to content

Commit

Permalink
Fix exception in inline frame processing (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvindshmicrosoft authored Jan 25, 2022
1 parent d548ba5 commit ec2ea6f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Engine/DiaUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ internal static string ProcessInlineFrames(string moduleName, bool useUndecorate
}
Marshal.ReleaseComObject(enumInlinees);
} catch (COMException) {
sbInline.AppendLine(" -- WARN: Unable to process inline frames");
sbInline.AppendLine(" -- WARN: Unable to process inline frames; maybe symbols are mismatched?");
} catch (System.ArgumentException) {
sbInline.AppendLine(" -- WARN: Unable to process inline frames; maybe symbols are mismatched?");
}

return sbInline.ToString();
}
}
Expand Down
9 changes: 8 additions & 1 deletion GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Microsoft.SqlServer.Utils.Misc.SQLCallStackResolver {
using System.Net;
using System.Globalization;
using System.Configuration;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Threading;

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

finalOutput.Text = backgroundTask.Result;

if (backgroundTask.Result.Contains("-- WARN:")) {
MessageBox.Show(this,
"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.",
"Potential issues with the output",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
}

private void DisableCancelButton() {
Expand Down
22 changes: 21 additions & 1 deletion Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void LargeXEventsInput() {
xeventInput.AppendLine("</Events>");
var timer = new System.Diagnostics.Stopwatch();
timer.Start();
var ret = csr.ResolveCallstacks(xeventInput.ToString(), @"..\..\..\Tests\TestCases\TestOrdinal", false, null, false, false, false, false, true, false, false, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
csr.ResolveCallstacks(xeventInput.ToString(), @"..\..\..\Tests\TestCases\TestOrdinal", false, null, false, false, false, false, true, false, false, Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
timer.Stop();
Assert.True(timer.Elapsed.TotalSeconds < 45 * 60); // 45 minutes max on GitHub hosted DSv2 runner (2 vCPU, 7 GiB RAM).
}
Expand Down Expand Up @@ -401,6 +401,26 @@ public void InlineFrameResolution() {
}
}

/// "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
/// Microsoft public symbols servers. https://github.com/microsoft/Windows-Driver-Frameworks/releases if interested.
[Fact]
[Trait("Category", "Unit")]
public void RandomInlineFrameResolution() {
using (var csr = new StackResolver()) {
var pdbPath = @"..\..\..\Tests\TestCases\SourceInformation";
var callstackInput = new System.Text.StringBuilder();
// generate frames with random offsets
var rng = new Random();
// generate 1000 frames, each frame having a random offset into Wdf01000
for (int frameNum = 0; frameNum < 1000; frameNum++) {
callstackInput.AppendLine($"Wdf01000+{rng.Next(0, 1000000)}");
}
csr.ResolveCallstacks(callstackInput.ToString(), pdbPath, false, null, false, false, true, false, true, true, false, null);
// We do not need to check anything; the criteria for the test passing is that the call did not throw an unhandled exception
}
}


/// Test for inline frame resolution without source lines included This test uses symbols for a Windows Driver Kit module, Wdf01000.sys,
/// 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.
[Fact][Trait("Category", "Unit")]
Expand Down

0 comments on commit ec2ea6f

Please sign in to comment.