| |
 Wednesday, October 27, 2004
As a follow up to my transitive exception post a little over a week ago, I hacked together a tool that almost does what I want.
See this page for some sample output, the results of running against the Whidbey Beta 1 release of mscorlib.dll (available as a free download off of MSDN). Notice that you get a full stack trace in cases where the method in question doesn't directly throw something, but rather a piece of called code does. It seems to be pretty accurate, and is actually giving me a warm and fuzzy feeling about the state of managed code and exceptions. It doesn't look like we let a lot of crap leak out of methods at all. Having a Java-heavy background, not having checked exceptions is seemingly giving me bouts of paranoia. :)
Here's a quick list of noted exclusions the tool doesn't currently handle at all:
- Late bound method calls. Virtuals, delegates, reflection, and the like.
- Well known system exceptions coming from infrastructure or unmanaged interop.
I have plans for both, but haven't had a chance to get something workable just yet.
You'll also notice that exception constructor arguments are actually captured and output, but only when literals are used at the call site. This is very seldom the case as a result of a little thing we like to call resources that are - thankfully - used pretty ubiquitously throughout the Framework. I'm planning on doing some reflection at the time of analysis to try and tease out the right resource string. I think it's pretty neat to see this data in the report.
I would publish the code for the tool, but unfortunately I've taken a dependency on some "secret-squirrel" (Hi Mark) static analysis technology that can't leave MS's comfy confines.
Diclaimer: This information is for research only, and should not be considered official Microsoft documentation of any sort. Please refer to the .NET Framework SDK for details on exceptions that a given method might throw.
 Tuesday, October 26, 2004
I subjected a friend tonight to the oh-so-exciting task of providing feedback on my book. I'm finding outside input very helpful actually, mostly because the separation of good writing from technical content is an important one to make. Others are good at providing a relatively objective opinion on the words and sentence structure itself. I simply despise the common excuse that just because someone's a nerd, they aren't able to communicate well (or even in a grammatically correct fashion). And they get away with it, too! Not to say that I have mastered these skills yet, but I digress...
Anyhow, here it be:
“This book is so boring, it has to be good.”
 Sunday, October 17, 2004
KitG posted the Nullable specification just the other day. To me as a Microsoft newbie (yes, I still recall what it's like on the outside), the fact that folks can now readily obtain previews of technologies and read the design specifications is pretty freaking cool... one step closer to complete transparency.
 Friday, October 15, 2004
I'm trying to quickly write up a tool to compute the transitive closure of all possible exceptions resulting in an invocation to a given method. Checked exceptions are an interesting means by which to attempt compiler enforcement of this. In Java, for example, exceptions that could be thrown are well known primarily because of strict inheritance rules, removing uncertainty by disallowing overriding methods to declare that they throw new exception types (aside from strengthening through polymorphism). The fact that you must either catch or declare that you throw an exception is simply a way to instruct the compiler what you intend to throw or let seep through the cracks. Arguably it could probably do a decent job (clearly not 100%, though) at figuring it out without requiring you to explicitly state it, however. And then perhaps it just becomes a compiler warning when you don't catch something.
Anyhow, I'm trying to hammer out the logic for my program and I came up with this. It's a bit cryptic, and I've probably used some symbols in uncommon ways... oh well... it helped me to think through the situation, and will be a great help when I actually implement it.
To compute the transitive closure of possible exceptions thrown as a result of an invocation to a method:
Let d be the method in question and a tuple of <td,md>, where td is the static type being analyzed and md is the method handle. Let C(d) be the set of tuples <iC(d)i,tC(d)i,mC(d)i>, for i = 0 to |C(d)|, representing method calls reachable from within d’s IL body (regardless of certain code paths and/or code path probabilities—probabilistic analysis could be quite interesting, but is not the focus of this effort), where iC(d)i is the instance on which a method is being called (or e for static method calls), tC(d)i is the static type to which the method call refers, and mC(d)i is the method handle being called.
Let DirThrows (d) be the set of exception types for which an explicit throw instruction is present within d’s IL body.
[informative] RefThrows(d) is defined below to equal the set of exceptions that could be thrown as a result of invoking a method call inside of d’s body, transitively closed on C(d).
Let Exc(d) be the set of exception types that could by thrown as a result of invoking method d. Specifically, Exc(d) = { DirThrows(d) È RefThrows(d) | deleting any e for which d‘s body contains an enclosing exception handler that catches e or a base-type and does not issue a rethrow instruction }.
Let RefThrows(d) be union of all Ei computed as follows:
For each <iC(d)i,tC(d)i,mC(d)i> Î C(d)
If virtual(<tC(d)i,mC(d)i>) is false, let Ei = Exc(<tC(d)i,mC(d)i>).
Otherwise, if there exists an assignment to iC(d)i of type u within visibility that provides an implementation for which virtual(<u,mC(d)i>) is false or whose instance construction is also within visibility and that can be deterministically proven to be the last known assignment (i.e. non-pointer local variable), let Ei = Exc(<u,mC(d)i>).
Otherwise, let T be the set of known derivative types of tC(d)i. If |T| = 0, let Ei = Exc(<tC(d)i,mC(d)i>). Otherwise, let Ei = { the union of all Exc(<u,mC(d)i>) for each u Î T }.
 Thursday, October 14, 2004
I'm feeling better about this book project each time I sit down to work on it. My word count is increasing steadily, and as expected my ability to get in “the zone” and crank out pages is indeed improving. My first draft is actually about 3% complete! :P

As I'm working on my book, I'm trying to remain conscious about making it accessible to as wide an audience as possible. This obviously includes the hobbyist and student crowd. As such, I've been working with the VS Express SKUs... and I must say, they kick mucho butt!
Check 'em out here: http://lab.msdn.microsoft.com/express/
Yeah, yeah, I probably sound like some marketing swine, but so be it. I've always been a fan of lightweight programming environments (emacs, csc, and nant was my standard “ide“ until recently), and these certainly feel more lightweight than Enterprise. Shhh... I won't go so far as to say I prefer Express over Enterprise - I haven't used Express enough to make an informed judgement, and I'm sure there are a slew of nifty features that didn't make it into Express - but when you just want to whack out a bunch of code and don't need a fancy shmancy IDE that supports multiple languages, client- and web- programming together, and the like: this dogfood tastes great.
 Tuesday, October 12, 2004
I need to set up a wiki or some other good means of capturing references and other interesting data. Bookmarks just don't cut it. In the absence of that, I'll just dump the top of my stack right here.
John McCarthy is a smart, smart man. The inventive capabilities of human beings never cease to amaze me.
Some Scheme papers...
A couple other random links...
I've been searching for and have only found a few digital copies of the papers referenced in the last link. This is a great candidate for a wiki so links can easily be added as they are located...
 Monday, October 11, 2004
Yep, one day Haskell and LISP will rule the world. Until then we'll just have to live with C# and its new closure-imitating syntax.
One of my design goals with the managed Scheme compiler is to enable easy interoperability with existing managed languages through delegate-based entrypoints. This communication needs to flow both ways, so that for example a lambda can substitute for a delegate and vice versa. My backend actually has its own representation for functions, enabling fine-grained control over scoping and such, but mutliple entrypoints are provided for this explicit purpose.
So for example,
delegate object Transform(object o); void Map(Transform a, Array arr) { //... }
Can be called from a Schema program as follows,
((func-lkup "Map(Transform, Array)") (lambda (x) (* x 2)) (10 15 20 25))
...and the other way around.
Krzys just blogged an update that I made a bit ago to the DesignGuidelines document. It's a bit of prescriptive guidance on when to use Factory-based object creation over traditional constructors, mostly influenced by what we've done historically in the Framework. This was actually my first update to “the DG” (as it's commonly referred to), and I've made a few others since then.
The most recent update I made taught me quite a bit during the writing process... I worked with RicoM, Don Syme, and Andrew Kennedy on it (I wouldn't have gotten the facts straight otherwise!), but a whole slew of other folks throughout WinFX also had a shared interest in seeing this topic documented. It's a fairly complicated and heated subject, but the bottom line is that under certain well-defined circumstances two NGen'd images could be unable to share generics instantiation code. In such a situation, the JIT will end up being called in. This ends up being pretty bad, especially when people often go to great lengths to avoid calling in the JIT altogether... surprise!
I'll look into posting the actual DG update over the next couple days... the original email thread on which we hashed out the logic might also interesting to some folks. Maybe I can post that too, in keeping with that whole transparency thingamajiggie.
I'm currently overhauling our guidance on finalization and disposability. The internal feedback keeps pouring in on these topics, and at this point I'm in a hurry just to get something out there to stop the bleeding! ;)
 Sunday, October 10, 2004
As mentioned previously, I ate at the Herbfarm last night... absolutely amazing. 9 courses, 5 hours. Too many glasses of wine. ;) The atmosphere at the restaurant was very different than any other. Many high-end restaurants are stuffy and uncomfortable even though they may serve up killer dishes and have great wine menus, filled primarily with folks entertaining business associates and the like. The Herbfarm, on the other hand, is truly a place for people who love great local, artisinal food and wine to gather and have a great night out.
For memory's sake, here's the menu (yes, that Madeira is from the year nineteen-hundred-one... it's not a typo!):
A Menu for A Mycologist's Dream Saturday, October 9, 2004
From the Gatherer's Basket Grilled Honey Mushroom with Spot Prawn Bears Tooth Mushroom with Sea Urchin Flan Poached Flat Oyster with Angel Wings 1998 Domaine Meriwether Brut, Captain Wm Clark Cuvee
Chestnut and Delicata Squash Ravioli With Cauliflower Mushrooms & Quince in Lemon Thyme Consomme 2003 Poet's Leap Riesling
Herb-Smoked Wild Sturgeon with Matsutake On Savoy Cabbage with Pear 2003 Patricia Green Cellars Chardonnay, Four Winds Vineyard
Lobster Mushroom, Hedgehog, Hawks Wing, and Blue Chanterelle Mushroom Terrine With Wilted Spinach and Bacon 2001 Beaux Freres Belles Soeurs Pinot Noir
Concord Grape and Rosemary Ice
Spice-Rubbed Muscovy Duck Breast With Two Gratins: King Bolete-Potato And Red Chart-Duck Confit 1999 Glen Fiona Walla Walla Syrah, Puncheon Aged
A Mycologist's Salad Chanterelles, Yam, Asian Pear & Quillisacut Goat Cheese
Harvest Festival of Desserts Hardy Kiwi and Lemon Verbena Tart Pumpkin-Bay Sundae Carmelized Apple Souffle With Orange-Thyme Custard Sauce
Brewed Coffees, Teas & Infusions
A Selection of Small Treats Vintage 1901 Barbeito Malvazia Madeira Herbfarm Yeasted Corn Bread & Multi-Grain Rolls Chive-Calendula Butter Coins
|
|
Me
Joe  is an architect and developer on a systems incubation project at Microsoft.
Recent
Search
Browse
Disclaimer:
The content of this site are my own personal opinions and do
not represent my employer's view in anyway.
© 2013, Joe Duffy
|
|