CLR internals, Rotor code explanation, CLR debugging tips, trivial debugging notes, .NET programming pitfalls, and blah, blah, blah...
Browse by Tags
All Tags »
.NET programming gotcha and debugging tips (RSS)
-
Some time ago I saw a problem from a partner team in Microsoft that an InvalidOperationException is thrown from WeakReference.IsAlive . WeakReference wraps weak GC handle implemented in CLR's Execution Engine ( GC handle is also exposed by System.Runtime.InteropServices.GCHandle Read More...
|
-
I got email asking me to explain !Threads output in details. I think this is a good question and a good topic for another installment to the series. Here is an example I'll use for this post: 0:055> !threads ThreadCount: 202 UnstartedThread: 95 BackgroundThread: Read More...
|
-
With knowledge in my previous blog , we could avoid some mistakes in .NET programming. A C++ Thread is very resource heavy. It is associated with a lot of dynamically allocated memory and some OS handles. So it had better to be cleaned up ASAP after its Read More...
|
-
If you use SOS’s !Threads command during debugging a lot, you should be familiar with such output: 0:003> !threads PDB symbol for mscorwks.dll not loaded Loaded Son of Strike data table version 5 from "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll" Read More...
|
-
One day I was debugging a problem where a Waston dialog popped up on a process. What surprised me was that on the stack where Waston was triggered, there was a unmanaged C++ function with a try-catch(…) block. To my understanding, this block should catch Read More...
|
-
There is a bug in this program below, try to see if you could catch it. Test.cs (compiled to DelegateExample.exe): using System; using System.Threading; using System.Runtime.InteropServices; class Test { delegate uint ThreadProc (IntPtr arg); private Read More...
|
-
I didn't realize I've stopped blogging for 1 year. What a shame! Fortunately I didn’t waste the time: we ship Whidbey Beta1 and Beta2 in the past year! Now with Beta2 out of door, I have more spare time for blogging. :) Today I want to talk about some Read More...
|
-
I've been quiet for 3 months and probably won't have much time for blogs for next several months down the road. Today I got a chance to update my post OutOfMemoryException and Pinning to correct a mistake pointed out by our GC architect Patrick Dussud. Read More...
|
-
Objects in CLR are usually managed by the runtime in GC heap; user code does not have direct access to the objects. CLR's reliability and type safety heavily rely on this fact. But CLR also support InterOp features like COM InterOp, IJW and PInvoke to Read More...
|
-
I've seen people calls OS's ExitThread in managed applications via PInvoke to exit a managed thread, like this: [DllImport( "Kernel32.dll")] public static extern void ExitThread(int exitCode); public static void Run () { ... // calling OS's ExitThread Read More...
|
-
As you all know, in CLR memory management is done by Garbage collector (GC). When GC can't find memory in preallocated memory chunk (GC heap) for new objects and can't book enough memory from the OS to expand GC heap, it throws OutOfMemoryException (OOM). Read More...
|