🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

The great 2008 bug hunt.

Published September 25, 2008
Advertisement
Sorry folks, no maze output tonight. I spent the night (and half of last night) hunting one bug. The bug manifested itself in double-lists: List> but only when Tangent types were involved. List> worked fine. The symptom was that the second indexer call would crap out in method group invoke saying no actual method group matched the runtime type.

Which should be impossible since the thing is checked at compile time and there's no type coercion yet. So I step through code and at the method group selection bit, the indexer is shown as Tangent.Lang.Object get_Item(int); and the parsed type was Tile get_Item(int) as it should've been. Kinda makes sense. I use the basic objects when tangent objects need to go to .NET land.

But the types never see that. The only way the indexer would ever get that is if I type parameterized List with Object explicitly. So I looked for that. And looked. Not only didn't I find it, but everywhere I saw List> I saw the correct typings. I stepped through the VM as the instance was created; as the inner list was created and added. Stepped through the passing of individual parameters between contexts and everything looked kosher.

I went back to the binding, where I import .NET types, where the methods are re-tied to types when bound... I double check that I'm not somehow polluting the cache with List and that's being erroneously returned... Nothing. Worse than nothing; nothing that even looked to be a likely candidate. No type after compilation even referenced Tangent.Lang.Object.

So I stepped through every instantiation to see where an object got that a type with the indexer's bad return value. That thankfully proved successful and let me trace the thing back. ~6 month old dormant code turned out to be the problem. When a .NET method is called, the result is stuffed into a return value field with a TangentType representation. Normally, the TangentType is pulled from the Tangent definition for the called method. Even for .NET invocations.

Abnormal is triggered when the return type was not a .NET type. For List> the first indexer's return type should be List but is technically a bound generic reference. It was not seen as a proper .NET type by the old code. The abnormal path was very helpful. It would reflect into the returned value's type and construct a TangentType for it. In this case, it saw List and helpfully used that as the returned instance's type. When the later indexer ran, the mis-typed instance didn't mesh with what it expected and exceptions got tossed.


And of course, there's still more layers of bug preventing the maze app from running. It compiles though, and last post's example code is still looking good. Just bugs in the compiler/VM. Tomorrow maybe, Friday more likely.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement