Obfuscation is Bad

Recently we ported our software to a more recent version of Visual Studio and the Oracle Client. The last application we delivered to test had some problems. Initially the work for this application was assigned to another developer. But when there were problems it somehow got reassigned to me. So I stepped up and took ownership of the problem. I was easily able to replicate the problem. However the code worked fine in debug mode. So I reverted back to the most basic of debugging techniques I know. I added print statements all over the code to locate where the application was bombing.

At first I found that all of the database calls from one of the modules were failing. Upon closer inspection of the project properties, I found that the release version of the module was still connected to the old version of the Oracle client. So I updated the project to use Oracle 10g. This got me a little further. But it did not completely resolve the problem. A bunch of print statements later, I discovered the problem was located within a C function called “trim”.

An educated guess made me believe the “trim” function did something like removing trailing white space or something. A quick scan of its source code made me feel a bit ill. There were absolutely no comments. That’s normally OK as I can read code as good as the next guy. But it seemed as though the function was obfuscated, either by design or by poor programming skills. There were lots of variables defined and used in the function that had really cryptic names. Some examples of the variables are tmp, tmp2, str, wk, and ln. There was also a bevy of if statements nested within each other that added to the confusion. The only thing that I knew for sure was that this function certainly was not just stripped the blanks off the end of a string.

Once again I relied on the good old print style of debugging. I found that the application was trying to write to some memory that was supposed to be protected. Unfortunately the compiler did not catch this. And somehow it worked fine in the debug version. So I fixed the problem. Then I did my duty and added some comments in front of the function describing what the heck the thing did. Now I did not go as far as renaming the variables. But I added a bunch of comments each time the variables were used to give a maintenance developer a chance of understanding what was going on. Now we just need to make sure we don’t write any more cryptic functions like this one.

Going Virtual

My company started up the current software maintenance contract in a strange mode. At first we bid the contract for developers to work out of our company’s headquarters, doing all our work remotely for the client. At the last minute the details were changed per the request of the customer. Instead we were to report to the client’s site to work. There was one big problem with this plan. They did not have cubicles for us to work out of. So our whole team ended up working out of a big lab at the client’s site.

Life at the lab is suboptimal. There are many challenges with performing work in this environment. One of the problems is that the network connectivity is not too good in the lab. Many of our developer servers are located in another building. The network speed between the lab and that building is slow. It takes forever to access code in our source code repository. Most of the time to do a software release is spent getting the latest version of code from the Rational Clearcase server.

The team brainstormed a solution to the slow network speed. Our best choice was to do our development work on virtual desktops located in the same building where our development servers are located. Now renting these virtual desktops come with a cost. But I think we pass these costs on to our client. It also takes a while and a lot of negotiating to get the system administrators of the virtual desktops to make configuration changes that we need. I am lucky in that I have admin rights on the virtual desktop that serves as our build machine.

We got a new Configuration Management team member. He had a task from his boss to find out which virtual desktop the build machine runs on, and to gain the ability to remotely connect to that machine. This CM guy came and asked me for information on the build machine. I told him the domain name of the virtual desktop. He came back telling me that he could not log on to the machine. I explained that there was a team that administered the virtual desktop machines. This team needed to grant the access he required. It is probably going to be some time before our CM guy gets access to this machine. There are benefits and drawbacks to going virtual like this. Right now we are experiencing some of the pain.

Review of C

By profession I am a C++ programmer. However I first learned the C programming language. Officially I only worked for one year on a job that exclusively required C. Ever since then the gigs were C++ programming jobs. However C++ is really an extension of C. And you can use a C++ compiler to work with C code. In fact, you can write C++ code but really be writing mostly C style functions.

The hard core programmers on my team are also C++ programmers. Every once in a while we get a Java or Visual Basic programmer who is moonlighting as a C++ programmer to pay the bills. Depending on whether we like these programmers, us C++ guys will either empathize with them or tease them. One current member of our team is a VB guy. And he gets the short end of the stick. The boys usually treat him like a substandard programmer. Because everyone knows that basic is not a real computer science programming language.

To get back at me, the Visual Basic developer gave me a copy of C Primer Plus. His intent was to inform me that, although I may be a C++ developers, I need to brush up on my C programming skills. Today I had to reinstall my Oracle Reports Builder software. This took a long time. So I decided to skim the C Primer Plus book. The table of contents mostly outlined topics I knew well. However I found the section on variable types quite interesting. So I decided to read and study up on it.

Here is a list of the different variable types in C. Do you know the difference between them? What is the scope of the different variable types? How long does the variable last and retain its value? Maybe the answers will be the topic for another post.
Automatic variables External variables Static variables Register variables


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser