Crouching tiger, coding monkey

lpr YouStupidPrinterTakeThis.txt

Filed under: Debugging, Linux, Printing — Grant May 10, 2007 @ 5:21 pm

The other day I had the joy and the privilege to debug some printing code. Oh yeah, it was as much as fun as you might be thinking. To make it even better the bug was showing up only on certain distributions of Linux. Seriously, you can dial back the jealously now, I already realize how lucky I am.

Cursing at the printer took me back to my days in college working in the computer labs. Back then Linux was old Infomagic CD’s and getting anything to come out of the printer, whether it was what you wanted or not, was a major accomplishment.

infomag.gif

*wavy screen and chime music*
*wavy screen and chime music*
*wavy screen and chime music*

The year was 1995-ish and this thing called the Internet was just starting to become all the rage. But that’s not really the point, that’s a cheap hook to set the tone and mood. Back then I was a “Student Lab Consultant” or some such title which translated directly into “Dude that sat at the desk with the phone in the public computer labs.”

Now being the dude with the phone meant that you did lots of things, but only three things were really important.

1. Help people clean off all the viruses they brought into the lab on the 3.5″ floppy disks that they’ve had since the 6th grade.

2. Consul them when said floppy from the 6th grade goes to that great disk drive in the sky taking their thesis with it.

3. Keep the stupid printers running.

That last one was the bad one. The first two the user had only themselves to blame, the other one was your fault. (Even if it wasn’t your fault, like say if there was no more blank paper in the lab.) It brings a warm feeling to my heart thinking about all the times an irate graduate student screamed at me because they couldn’t print out their research paper for a class that started in two minutes. No matter how many times I told them that a “A Study of the Radiation of the Enzyme Aldehyde Oxidase Decoduosomethingoranother in the Fruit Fly Drosophila melanogaster” probably wasn’t going to be a best seller it didn’t matter.

In fact, it is probably a testament to my fight or flight breakaway speed that I wasn’t bludgeoned to death with a toner cartridge. Or perhaps a thesis about fruit flies.

Regardless, the lesson then still applies today, printers are out to get you at all times. They are not be trusted and must be watched carefully. Speaking of which, I haven’t seen that LaserJet in a while, I wonder where he is…

Virtual virtual debugging or “How I got an ID10T error from Parallels”

Filed under: Debugging — Grant September 28, 2006 @ 10:24 am

Yesterday I was minding my own business when a bug slipped into my queue. We’ll call him, oh I don’t know, Defect #327. (I’ll give you one guess where I got that name from.) It goes something like this:

Defect #327: Windows NT4: Ordinal not found error: “The ordinal 301 could not be located in the dynamic link library WLDAP32.dll”

Apparently this was discovered using a Virtual PC image but everything had worked fine on the test machines that were running NT4 natively. I figured that the Virtual PC image hadn’t been patched up to the right level, but in order to know for sure I had to run it and see. Here is where the craziness begins.

I have two computers at work. One is the wickedly good Macbook Pro that 90% of all of my work is done on. The other is an also wickedly good, but not nearly as cool, Dell GX260 workstation running Windows 2003. Figuring that Virtual PC would run better on Windows than the Intel Mac I wheeled over to the Dell and set about installing it.

I browsed to the network shares, click click open the directory, setup.exe that looks right, click some more, installer starts here we go:

“You are not running a supported operating system. Microsoft Virtual PC 2004 is only supported on Windows 2000 Professional and Windows XP Professional.”

D’oh.

All right, well I couldn’t put XP on that box for other testing reasons, so I figured I would just do a fresh install of NT in Parallels on my Mac. So I start up Parallels, dig around the network room for the NT4 CD, setup the VM, launch the installer:

Ah, error number 4.  Of course.

Shaking a first at the screen I mutter the words of Homer J. Simpson, “Oh cruel fate, why do you mock me?” I mean, how hard could it have been for the NT4 team to anticipate my needs? Shouldn’t they have thought that I would need to do an install on a virtual machine product that hadn’t been invented yet (Parallels), on an OS that hadn’t been invented yet (Mac OS X), on a chip platform that Macs were a decade from running on (Intel)? Hmm, I guess when I put it that way…

Being 0 for 2 in my attempts it was now time to try the crazy scenario, run NT4 in Virtual PC on XP Pro that was running in Parallels on Mac OS X. A virtual virtual OS. Admittedly I had very little hope that this would actually work, but what the hell, I had come this far.
After booting up Parallels with XP and successfully installing Virtual PC it was the moment of truth:

Virtual PC in Parallels

Come on, big bucks, no whammies…

Whammy! Parallels crash report

Kablooey! There’s the surprise of the century. Parallels will crap out if you try to start a Virtual PC virtual machine inside one its virtual machines. Along this same line, other things I have recently discovered is that water is wet and things on a stove tend to be hot to the touch.

Having screwed around enough I finally buckled and installed Virtual PC on one of the QA machines in the lab. Turns out I was right, the latest patch hadn’t been installed to the disk image so that’s why we were seeing the error. And it only took me three real machines, two and a half virtual machines, and one reference to an old game show to figure it out.

And who says Apple is always the one that has style?

Filed under: Debugging — Grant August 23, 2006 @ 9:58 pm

So I was debugging some code a while back on Linux using gdb from the command line.

Oh yeah, old school.

Anyhow, during one of my runs I accidentally attached gdb to its own process. It went something kinda like this:

lammig@linux-mbp:~> gdb
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i586-suse-linux".
(gdb) shell ps
PID TTY TIME CMD
4630 pts/1 00:00:00 bash
4713 pts/1 00:00:00 gdb
4714 pts/1 00:00:00 ps
(gdb) attach 4713

I refuse to debug myself!

(gdb)
lammig@linux-mbp:~>

Now that is one cool error message. In fact, that is quite possibly the best error message I’ve ever seen. This got to me wondering, is it the same for gdb on different platforms? Let’s take a look on FreeBSD…

cerebro/lammi:~ (1) gdb
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i386-marcel-freebsd”.
(gdb) shell ps
PID TT STAT TIME COMMAND
66600 p4 Ss 0:00.04 -tcsh (tcsh)
66609 p4 S+ 0:00.01 gdb
66610 p4 S+ 0:00.01 tcsh -c ps
66611 p4 R+ 0:00.00 ps
(gdb) attach 66609

I refuse to debug myself!

(gdb)

Rock and roll, score two for the open source OS guys. Now this made me wonder, with all their crazy attention to detail, what would Apple do with something like this.

There’s only one way to find out…

lammi-mbp:~ lammig$ gdb
GNU gdb 6.3.50-20050815 (Apple version gdb-563) (Wed Jul 19 05:10:58 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".
(gdb) shell ps
PID TT STAT TIME COMMAND
261 p1 S 0:00.03 -bash
299 p1 S+ 0:00.03 /usr/libexec/gdb/gdb-i386-apple-darwin
(gdb) attach 299

unable to debug self

(gdb)

unable to debug self?

You’ve got to be kidding me. It’s not even a sentence. There’s not even capitialization or punctuation. Aye caramba.

Just for kicks let’s see how stodgy old Solaris talks to us…

bash-2.05$ /usr/local/bin/gdb
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.9".
(gdb) shell ps
PID TTY TIME CMD
1579 pts/1 0:00 bash
1585 pts/1 0:00 gdb
1586 pts/1 0:00 ps
(gdb) attach 1585

Attaching GDB to itself is not a good idea…

(gdb)

Come on Apple, even Sun of all places has a fun error message. I wonder if I should submit a bug to see if they can fix it in Leopard?