views:

92

answers:

2

Folks,

I've got a stack overflow in my .net 4.0 app. using WinDbg I've found the following chunk of stack-info repeated 110 times (with different memory addresses of course), which leads me to believe that this is the case of the overflow. The issue is that none of this seems like my code! Any suggestions on how to proceed with debugging?

000000000008e630 000007fef22d10b4 [CustomGCFrame: 000000000008e630] 
000000000008e5f8 000007fef22d10b4 [GCFrame: 000000000008e5f8] 
000000000008e588 000007fef22d10b4 [GCFrame: 000000000008e588] 
000000000008e958 000007fef22d10b4 [HelperMethodFrame_PROTECTOBJ: 000000000008e958] System.RuntimeMethodHandle._InvokeMethodFast(System.IRuntimeMethodInfo, System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeType)
000000000008eaa0 000007fef138587f System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean)
000000000008ebe0 000007fef13d000f System.Delegate.DynamicInvokeImpl(System.Object[])
000000000008ec50 000007feeee16127 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry)
000000000008ec90 000007feeee16004 System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)
000000000008ed20 000007fef1393178 System.Threading.ExecutionContext.runTryCode(System.Object)
000000000008f448 000007fef22d10b4 [HelperMethodFrame_PROTECTOBJ: 000000000008f448] System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
000000000008f570 000007fef13817e1 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
000000000008f5d0 000007fef138172b System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
000000000008f620 000007feeee15f31 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)
000000000008f680 000007feeee15b97 System.Windows.Forms.Control.InvokeMarshaledCallbacks()
000000000008f700 000007feeedfb7da System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
000000000008f8b0 000007feeee09a0d System.Windows.Forms.Form.WndProc(System.Windows.Forms.Message ByRef)
000000000008f990 000007feeedfb34c System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)
000000000008fa60 000007feef60ef10 DomainBoundILStubClass.IL_STUB_ReversePInvoke(Int64, Int32, Int64, Int64)
000000000008fd98 000007fef236cae7 [NDirectMethodFrameStandalone: 000000000008fd98] System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG ByRef)
000000000008fd60 000007feeee271a0 DomainBoundILStubClass.IL_STUB_PInvoke(MSG ByRef)
000000000008fe30 000007feeee151d0 System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
0000000000090070 000007feeee149d3 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
00000000000901d0 000007feeee14361 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
0000000000090948 000007fef22d10b4 [DebuggerU2MCatchHandlerFrame: 0000000000090948] 
0000000000090a30 000007fef22d10b4 [CustomGCFrame: 0000000000090a30] 
+1  A: 

I'm (just) guessing that this is a good example of why not to use Application.DoEvents(), but you should have at least some idea of what code causes this.

Henk Holterman
Turns out I was asynchronously marshaling many ui updates through the UI thread (using Form.BeginInvoke). The method that made the ui updates was calling Application.DoEvents(). I removed the call to DoEvents and instead followed the advice here: http://blogs.msdn.com/b/jfoscoding/archive/2005/08/06/448560.aspx
SFun28
+4  A: 

It looks like your app is recursively reentering its UI message loop. Check your window's event handlers, e.g. for things like resizing the window while processing a Resize event.

Frédéric Hamidi
This was a good guess. Thanks for clueing me into the UI issue!
SFun28