Stacktrace constructor hangs

  • Thread starter Thread starter Kurt Biesemans
  • Start date Start date
K

Kurt Biesemans

Hello,

I have a line code : StackTrace stackTrace = new StackTrace(false);
When I run the project in debug, the application keeps hanging on this line.

My Environment:
Windows 2003 Server Standard SP1
Visual Studio 2003 SP1

Any help is welcome

Kurt Biesemans
 
If you can boil this down to a simple reproducible example, please post
the code here that hangs and I will take a look at what might be
happening.
 
Hi John,

I made a simple application that executes the specific line that hangs.

My application exists of 2 classes.

FIRST CLASS: Name = MAIN.CS

using System;

namespace StackTraceTest

{

public class MainClass

{

[STAThread]

static void Main()

{

Processing processingClass = new Processing();

Console.WriteLine("BEFORE CALL TO PROCESSING");

processingClass.CreateStackTrace();

Console.WriteLine("AFTER CALL TO PROCESSING");

}

}

}

SECOND CLASS: Name = Processing.cs

using System;

using System.Reflection;

using System.Diagnostics;

namespace StackTraceTest

{

public class Processing

{

public Processing()

{

}

public void CreateStackTrace()

{

Console.WriteLine("BEFORE CREATION OF STACKTRACE");

StackTrace stackTrace = new StackTrace(false);

Console.WriteLine("AFTER CREATION OF STACKTRACE");

int stackOffset = GetCallerStackOffset(stackTrace);

StackFrame stackFrame = stackTrace.GetFrame(stackOffset);

int callerOffset = stackTrace.FrameCount - stackOffset;

}

private int GetCallerStackOffset(StackTrace pStackTrace)

{

int stackOffset = 0;

// Lookup for the method of the object speaker caller.

while (stackOffset < pStackTrace.FrameCount)

{

// Collect information from the call stack.

Type speakerObject = this.GetType().BaseType;

StackFrame stackFrame = pStackTrace.GetFrame(stackOffset);

MethodBase stackMethod = stackFrame.GetMethod();

// Evaluate if the method belongq to the abstract object speaker.

if (stackMethod.DeclaringType == speakerObject)

{

stackOffset++;

continue;

}

// Evaluate if the method belongq to a specific object speaker.

if (stackMethod.DeclaringType.BaseType == speakerObject)

{

stackOffset++;

continue;

}

// The method does not belong to an object speaker.

break;

}

// Provide the stack offset of the caller method.

return(stackOffset);

}

}

}

Please let me know if you need more info.

Kurt
 
There is nothing special about this example that would make expect it
to hang, and when I gave it a try, it did not hang for me.
Could you provide an UnManaged StackTrace of the application when it is
hung?

Otherwise, just keep making the situation simpler and simpler until the
hang no longer occurs. Then you will know the one magic piece of the
puzzle that causes the hang. Once you have that you will either have a
work-around or a more solid bug report.
 
Back
Top