May 24, 2011

Oh Stacktrace, My Stacktrace...

Do you remember the first time you wrote a Wizard for Eclipse? Do you still know what went wrong the first time (and maybe a few times more)? Let's assume you wrote a wizard page like the one below which just contains a simple text widget inside the page's composite:


It's not necessarily a fancy UI nor complete but it doesn't look obviously wrong, right?
However, when you run the wizard it just fails without any error message.
A look into the error log reveals that there is a problem with JFace - but not your code:

Now, you might guess that this exception is caused by you, but frankly: When I wrote my first wizard page I was quite sure I didn't make any mistakes... God, yes. How wrong I've been...

After googleing for an explanation for a while, I found out that I was missing just one simple method call. Namely, calling setControl(..) on my wizard page. I figured this out thirty minutes later - what a great waste of time...

But as I've learned from my talk at Eclipse Summit, I'm actually not the only jerk doing this wrong.  I asked the audience to raise their hands if they know that error - and after a while they started grinning and one-by-one raised the hand to show that they experienced the same problem just some time ago. How about you? Do you know it too?

Let's see what Google returned me when I pasted the first line of my exception into its search box: ("null argument: has no page control" is part of the query but was cut off in the screenshot):


Google obviously does not a good job here. It still doesn't know the answer - even after years this error (better: wrong usage) exists.
So what can we do to get rid of this? Bug trackers like Jira and Bugzilla (with Mylyn extension) have shown the way. These tools have duplicate stacktrace detectors that, whenever they observe a stacktrace in a new report, query the bug database for bugs that contain similar stacktraces.
And guess what: They work - and not too bad! To evaluate that, we replayed the bug reports from Eclipse Bugzilla from 2001 to 2008 one by one and for each new bug report containing a stacktrace we tried to find the corresponding bug id this new report was marked as duplicate of). The amazing result: In ~70% of all cases we found the right bug id under the top 3 positions! Goodbye duplicates - if you submit a stacktrace...

Just another example. Maven had a neat feature that whenever an exception occurs during a build, it printed out a message that directs you to some wiki page which may contain further help about this error. Unfortunately, these pages have been mostly empty (at least for the cases I looked at them). However, the idea is great!
What if there would be a place where you can send your stacktrace to and get a list of resources in the web that discuss exactly your problem? With such a help it should be quite easy to nail down and fix your problem in just a few minutes, right? You may think of it as being similar to  stackoverflow.com - but just for stacktraces. Something like stacktraces.org - or stacktraces.eclipse.org - a repository which contains stacktraces of the users, error descriptions and solutions including pointers to resources in the web that deal with these problems.

What we have in mind is something like this: An Eclipse client that listens for exceptions printed on the console or written into the log:

which are parsed automatically by the tool Whenever it observes an exception it may show a pop-up (3) which starts a search dialog that shows your most recent stacktraces:
If you know click on "search" it will search stacktraces.org for similar stacktraces and returns pointers to resources in the web that deal with similar stacktraces - it may even include a discussion on this stacktrace with some explanation of what caused this exception and how to fix it. This summary could be displayed in your browser or directly in Eclipse as shown below:


Additional tabs may provide additional information like similar stacktraces, related web-resources etc.:

That's just a thought about how we could get rid of it. Best of it: in its minimum version there is no additional effort of a user required. We may just give pointers to existing resources or we may integrate the results into a forum etc.
What do you think? 
Would you use such a stacktrace search engine that leverages the community knowledge about common pitfalls and usage errors of your favorite open source project? How much time you could have saved if someone had pointed you directly to the forum post telling you that you simply forgot to call setControl.

Just click on the like/dislike button below - and if you have a few minutes, feel invited to drop a comment below.

Thanks, 
Marcel

Update #1:

If you like the idea you may also consider commenting on it at/for stackoverflow.com.


Stay in touch: Follow me on Twitter.