Friday Feb 06, 2009

GC debugging + surfing + nutrition?

      A year ago I was tracking down a garbage collector bug in Squawk over many days. Like most debugging, you start with a theory of what might be going wrong, figure out what data would prove or disprove the theory, and try to reproduce the bug while getting this critical data.
recycle logo
But now life starts getting interesting. We can't use a debugger on device when the system is this broken. And the system is built on an abstraction of objects (almost everything in Squawk is written in Java), but when memory overwrites can blow away metadata like object lengths and class pointers, you realize that you can't trust everything you see.

This isn't the profound, but ultimately simple, betrayal of the ground during an earthquake. Garbage collection can effect every object in the heap, so garbage collection bugs are more like betrayal in a bad Kung Foo movie:


I had spent a few days and several dives down into the system, only to rise to the surface with theories disproved or becoming deeply disoriented. So one morning, I started with a new theory and tools, took a deep breath, and dove into the system again. Suddenly I was struck with a flashback of body surfing as a kid at Hendry's Beach and getting slammed by waves, tumbling around until I didn't know which way was up. cc

After reminiscing for a few minutes, I realized how amazing it was that my metaphoric dives and confusion could invoke such as strong memory. I could feel the oily tar residue of the ocean in my mouth. I could taste the seaweed that always reminded me of ice cream and of the kelp harvesters on the horizon.

I started thinking about how high-level metaphors could trigger such low-level sensory memories, when a sudden small burp reminded me of the fish oil pills and smelly vitamins that I had washed down that morning with a cup of hot coffee. Lesson learned :-)

ps. There was still a GC bug to fix. It turned out that we were removing the stack object (yes, it's an object) for a dying thread from the set of GC roots while the thread was executing the last few steps of thread shutdown. Yikes!

Monday Dec 08, 2008

The treasure past the dragon (beyond Scratching the surface)

My sons have been playing with Scratch, a programming language/system for kids to build games, video, etc, and share them on the web. Although I've seen plenty of graphical programming languages for kids over the years, Scratch does a really good job of making it trivial to share projects on the web. Not only can kids on the web play each others creations, but they can download, explore, learn, and remix, and upload them. So the kids can learn a lot from each other.

Scratch has been my sons thing - I've answered the odd question about variables (in general), but otherwise have stayed mostly ignorant of how Scratch really works (this protects me from overloading on pokemon and waffles).

 Saturday, MIT sponsored a Scratcher Meetup at the Media Lab and invited 80 or so kids.

I ended up learning at least as much as my kids at this meeting. First, even though though I worked for Dan Ingalls for a while, and my partner in crime Eric is an unrepentant Smalltalk hacker, I hadn't realized that the system my sons were using was based on Squeak, the smalltalk-in-smalltalk VM that inspired Squawk.

 Even more interesting was that a couple of kids at the meetup had figured out that from within Scratch, they can trigger a runtime error that brings up a Smalltalk class browser. From the browser they could create their own Scratch blocks (the programming primitives in the visual programming environment)!

These kids could be found in the meetup tracking down the Scratch developers, getting tips on how to interface properly with Scratch. The developers did their best to teach them, even though their jaws had dropped permanently to the floor :-O

 To me this seems an inspiring and magical way to learn hacking and programming - the keys to the kingdom are through the secret door past the dragon...


Out of the fog... of bits, bytes, and really small Java Virtual Machines, by Derek White. The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.


« April 2014