*

The Baby Bunny Mini-Lecture: Part 2

There are actually a few different ways a Baby BunnyT can happen.

  • A bizarre random act of computer possession in which a perfectly good file mysteriously goes corrupt; I've seen this happen when a .dll is moved out of the expected folder, the program is run and oops well I guess we'll be moving that file back to where it come from, and the .dll moved back. It's almost like it picked up extra information. (Maybe the scent of the other folder rubbed off on it...)
     
  • An act of mischief where a file that in no way, shape, or form was ever supposed to be a .dll gets named .dll and placed where the real .dll is supposed to be. A wolf in baby bunny clothing, in effect.
     
  • An old or new version of your .dll replaces your working one. This is what happened in yesterday's shareware incident.

So, how is it that an old dll or even a new "improved" dll causes the Baby BunnyT Effect?

Let's say you create component Z. It has three methods, Liminal, Way, and Terranean (originally created as Sub procedures). You distribute component Z to your users and life is happy.

About two months later you are asked to revise component Z. Version 2.0 of the front-end was written and it turns out the method Way is not being used at all and method Liminal needs an argument of data type Long. "No problem!" you proclaim, "Changes coming right up!" You open up your trusty VB project (which, BTW, defaults to Project compatibility), delete method Way, add an argument of Long to method Liminal, compile and redistribute the component. Life is happy again, right?

Nuh uh.

The Roswell office got the memo about the new component Z and installed it on their server, but did not get the memo about installing the new and improved Front End 2.0. So, an employee revs up the app they have, Front End 1.0, which makes a call to method Liminal but doesn't pass along an argument. The new and improved component Z is not pleased, the Baby BunnyT rears its furry head and "run away! faster!" echoes through the hallways. Meanwhile, Area 51 got the memo about the new Front End 2.0, but did not get the memo about the new component Z. When the new app makes a call to the old method Liminal, passing along an argument, the same message box "cannot find z.dll" pops up.

To add insult to injury, later that day the Roswell Front End 1.0 is run again. Skillfully concealed somewhere on an obscure configuration tab lurked a call to method Way. And while the typical calling card of the Baby BunnyT - "cannot find z.dll" - did not present itself, the dreaded logic error (or at the end of the day 1 + 1 does not equal 2) did. Basically a stealth Baby BunnyT.

The first instance, where the calls to method Liminal failed, is simply a matter of knowing that calling a procedure without passing along any required argument makes your component revolt, as will sending an argument to a procedure that accepts none. To understand the second instance we need to look under the hood at the vtable. When the original component Z was compiled, it gave ordinal values to methods Liminal (0), Way (1) and Terranean (2). When functionality is deleted from your component and the vtable is recreated during compile, the order of the called ordinal values is compacted. In other words, because you deleted method Way from position 1, method Terranean moves up to position 1. When the older front-end application was compiled, it did not refer to methods Way or Terranean, but to its calling number, specifically 1. So, when it calls 1, expecting to use method Way, it gets method Terranean instead. Now 1 + 1 equals 56,345 light years.

Had component Z's project been set to Binary compatibility instead of Project compatibility you would not have ended up with a compiled component that would cause problems with legacy applications. Not that VB would stop you from doing so - it would at least have given you a couple of warnings that changing the number and data types of arguments and deleting functionality might cause problems later on.



Internet Content Rating Association Valid CSS!

Alrak's Course Resources ©2002-2007 Karla Carter. All rights reserved. This material (including, but not limited to, Mini-lectures and Challenge Labs) may not be reproduced, displayed, modified or distributed without the express prior written permission of the copyright holder. For permission, contact Karla.