The limitations of not actually knowing a language

June 28, 2013

As a sysadmin I've developed over the years a decent facility in what I've been known to call 'chainsaw coding', which is where you go in to a codebase with no knowledge of the code and possibly only a vague knowledge of the language, and chainsaw in a change that actually works. I actually know C, which means that I can get quite far with chainsaw coding in any number of related languages; I can sort of read Java and C++ is usually close enough to C that I can get by pretty well. All of this is great when it works. But it only goes so far, and every so often I (painfully) run up against the limitations imposed by my own actual ignorance. As you might guess from me writing about this now, I'm currently in such a situation.

Ever since my twitter client was updated to deal with the new Twitter API (which I was very happy to see), it's had a bug that causes it to periodically dump core. I have stack backtraces with full symbols and they are very consistent, and based on some information in the stack traces I suspect a null pointer dereference issue although I can't be sure.

(The stack traces say that a this pointer has a very odd value. I've been conditioned to suspect that odd values, especially odd low values, are the result of trying to use a null pointer as a pointer to a structure and then accessing a member of it. You get odd low values from '0 plus some structure member offset'. But this is all C logic and I don't know how much of it applies in C++.)

Choqok uses QT and is written in what I'll call 'real C++', by which I mean C++ that actually has a lot of objects, a lot of method calls, and in general a lot of things where the difference between C and C++ really matters. As a result of this I can't really read this code with any genuine understanding because I don't actually know C++, I just fake it. Oh, I can take guesses and many of my guesses may even be correct, but I know full well that I'm making assumptions. Lots of assumptions. Too many assumptions to really try to debug the code based on them.

(As it stands I don't even feel confident in adding printf() calls because I have no idea what side effects might happen if I tried to generate string representations of various data structures. I suppose this means that for once I should be using GDB so I can poke around in memory when the next crash happens.)

This is not choqok's fault. I'm sure its code is perfectly well structured for people who know C++ (and possibly QT). The problem is me; I've hit the limitation of not actually knowing C++. It's kind of annoying, partly because I'm an impatient person who's used to being able to take a real shot at debugging things that look like simple problems.

Written on 28 June 2013.
« How much of our incoming email is checked at SMTP DATA time
connect() plus write() versus sendto() for UDP sockets »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Jun 28 01:13:51 2013
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.