Skip to content

Commit

Permalink
Merge branch 'pr-2267'
Browse files Browse the repository at this point in the history
fix(clrclore): ignore captured traces if null (pr-2267):
 - d08c6e7 fix(clrclore): ignore captured traces if null
  • Loading branch information
thorium-cfx committed Nov 6, 2023
2 parents 355529f + d08c6e7 commit d46956b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion code/client/clrcore/InternalManager.cs
Expand Up @@ -585,14 +585,15 @@ private void PrintError(string where, Exception what)
IEnumerable<StackFrame> stackFrames;

// HACK: workaround to iterate inner traces ourselves.
// TODO: remove this once we've updated libraries
var fieldCapturedTraces = typeof(StackTrace).GetField("captured_traces", BindingFlags.NonPublic | BindingFlags.Instance);
if (fieldCapturedTraces != null)
{
var captured_traces = (StackTrace[])fieldCapturedTraces.GetValue(stackTrace);

// client's mscorlib is missing this piece of code, copied from https://github.com/mono/mono/blob/ef848cfa83ea16b8afbd5b933968b1838df19505/mcs/class/corlib/System.Diagnostics/StackTrace.cs#L181
var accum = new List<StackFrame>();
foreach (var t in captured_traces)
foreach (var t in captured_traces ?? Array.Empty<StackTrace>())
{
for (int i = 0; i < t.FrameCount; i++)
accum.Add(t.GetFrame(i));
Expand Down

0 comments on commit d46956b

Please sign in to comment.