A long, long time ago when C was all the rage and C++ was just coming into its own, many people that were running applications on Unix boxes used the X-Windowing system created by MIT to build their GUI applications. This was the GUI equivalent of programming in assembly; it worked, but was cumbersome and hard to do. Shortly thereafter, the Xt-Intrinsics library was created as a wrapper, which provided higher level entities that were easier to work with. Shortly after that, several higher level toolkits that were even easier to use were created. Among these was Motif, created by DEC, HP, etc.

While these higher level libraries were easier to use than raw X-lib, they were not without their problems.

Sam was a senior developer at Military Widgets, Inc. His responsibilities included the usual architectural/development duties on his project. One day, Pat, Sam's boss, asked him to stay late. "Taylor has a bug that he just can't crack," Pat explained. "I want someone with a little more experience to give him a hand."

It seems that after making some changes to their Motif GUI, the application started throwing stack dumps on every transaction. As a result, every transaction was rolling back as failed. Taylor insisted that his code was correct and that it was not the cause of the problem. To this end, Pat asked Sam to stay late one afternoon and take a look at it.

After some company-sponsored pizza, Pat had Taylor hand Sam a stack trace. In the middle of it was a call to:


    XmTextSetString(theWidget,"String to display");

Sam laughed. "Taylor," he said, "this macro has a known memory leak." Since the macro was just a wrapper, Taylor should just replace it with the corresponding underlying call to do the actual work:


    XmTextReplace(theWidget, 
                  (XmTextPosition) 0,
                  XmTextGetLastPosition(theWidget),
                  "String to display");

This was long before Tim Berners-Lee created the internet on top of DARPA-net, so all they had to go on was a very thick set of printed manuals. Taylor pulled out the Motif manual and showed Sam the proper use of the XmTextSetString macro. "I followed the procedures laid out in the manual."

"Just because it's in the manual, doesn't mean it's *right*," Sam said. "The Motif code has a bug in it. That does happen, you know."

Taylor insisted the problem must be someplace else. "I followed the instructions in the manual!" Sam looked at Pat, raised an eyebrow and sighed.

Pat asked Taylor to try the change. Taylor refused, insisting that he did it right and that Sam didn't know what he was talking about.

Sam said he was going to his desk and would have it temporarily patched in 5 minutes.

He opened a file called last.h, and undefined the XmTextSetString macro and then redefined it using his fix. Then he kicked off a 3.5 hour full build, opened another window and typed the command to run the server, but did not enter it.

Sam returned to the conference room, explained what he did and told Taylor to keep moving the mouse to keep Sam's box from closing. Then in 3.5 hours, he could hit ENTER and test the result.

He told Pat that there might be other problems that they could encounter at other points in the application, but this WAS the cause of this problem, and that he'd see that in several hours. He also pointed out that this was only a hack, that it should NOT be checked in, and that all of the actual macro uses should be replaced with the correct code. Then he went home, relegating Taylor to several hours of jiggling a mouse, all the while mumbling that this wouldn't work because he had done it right.

When the build finished, Pat watched as Taylor launched the server, and brought the GUI to the last keystroke before the error had been occurring. To Taylor's surprise, the transaction went through without the exception. Pat then had him jam a whole year of transactions down that pipe via their batch mechanism. It took all night but it worked.

The next day, Pat had Taylor manually tracking down and replacing every instance of that macro with the corrected code, because doing what the manual says without verifying that it's right is NOT doing it right.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!