Yes, your patch is correct, because your patch keeps the same meaning with the old code exactly, I think it is absolutely right.
I also think there is still space for improvements for track/untrack. In the current implementation, if the object is extended, we need the track/untrack the old object, then track the right object. This is ugly.
In patch-C3120-20110625.txt, firstly, I carefully investigate which code throws which exception, so I can take care of them seperately (in fact, I found that the excetpion handling can be simplified). Secondly, I carefully read the code, who will use/affect the tracked object, I found that, in the LockEngine.load method, before the molder.mold(), the tracked object is not useful.
So I think we just need to track the object before it is used. So we just need to track the right object (no matter extended or not).
So I think in patch-C3120-20110625.txt, the code is simplified, and the same meaning is stayed.
After the patch for 3199 (20110623), the test4 will pass.
If exchange the lock and track sequence, the deadlock will show. I don't know why yet.