Mysterious Lag Spikes and Faulty Switches
My residential internet experience has always been poor, so when I started observing bizarre network behavior a few months back I attributed it to upstream problems and wrote it off with a sigh. The issue persisted however, so over the winter break I decided to sit down and tackle it once and for all.
Tracking down the source of the issue was an interesting adventure, and ultimately the problem was in the last place I thought to check: a pair of TEG-S80g unmanaged gigabit switches made by TRENDnet.
Do not buy! :)
Details follow.
Catching pointer overflow bugs
In all varieties of C/C++, pointer arithmetic is undefined if it overflows. That is to say the following example:
void invalid(char *p) {
char *q = p + 1;
printf("%p\n", p - (uintptr_t)q);
}
invokes undefined behavior as it causes the pointer value to
wraparound to the equivalent of -sizeof(char)
, which is
0xffffffffffffffff
on my 64bit system.
Unlike integer overflows which can be dangerous or benign regardless of intention (ICSE12), pointer overflows are very unlikely to be intentional and may be the source of a more serious bug resulting in incorrect behavior or program crashing.
Kernel hacking: My very own BSOD
While working on hacking the FreeBSD kernel for a research project, I of course have crashed things many times. Hooray for VM’s.
However, this latest time I’ve managed to really mess things up. Instead of some esoteric message in the logs, the result was the following being written to the console:
Hopefully those of you who’ve hacked on kernels previously will appreciate the “wut” moment you get when your screen looks like this instead of acting as expected :).
Bootswatch Theme Selector
Despite my passion for light-on-dark themes, not everyone finds them as readable and enjoyable as I do. To address these concerns I investigated what it would take to add a drop-down to this website to enable dynamic selection of themes by the user.
The relevant code is given, but for those interested in a complete example take a look at the website github.
Easy Website Tuning
Having recently moved to Pelican, I found myself interested in seeing how I could coerce my server (runing Apache) into taking proper advantage of the bulk of the website being static.
There’s lots of information on the subject out there, but below I describe the few easy changes I made to greatly improve performance of my website.