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:

Sensei-you've-raised-me-from-childhood-but-are-really-the-re-incarnation-of-my-father's-evil-half-twin-(and
killer)---Is-nothing-you've-taught-me-true?!!!


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!

About

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.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today