Archive for September 20th, 2008

Linux integer overflow signal handler example

I was chatting in #c on freenode.net the other night and someone was asking about detecting numeric overflows. Apparently they were interested in writing their own language as a learning exercise, and wanted some of the niceties that other languages offer, such as overflow detection.

After a quick bit of poking around, I found that GCC has the -ftrapv option, which will generate a trap on signed integer addition, subtraction, multiplication and division. Now that I knew a trap (or signal) could be generated, some code was needed to demonstrate it.

About 5 years ago I worked on a project that handled a bunch of signals. If a segment fault (SIGSEGV) was received, it would print a backtrace of the stack and display the processor registers. A bit of cutting and pasting and some minor updates, and it worked.

At that point, I figured I ought to make an example out of it, since there seems to be little in the way of readily available documentation for this sort of things. You can find tutorials on basic signal writing, but if you want to dump the stack or processor registers, you have to start digging through the source code of libc, glibc and gdb (which is pretty much how I figured out how to do this in the first place).

This example is available on my wiki, at http://www.tinymicros.com/wiki/Linux_Overflow_Signal_Handler_Example.

Comments and criticism are welcome.

An interesting house

Left side view

Right side view

Today the weather was just too nice to stay inside any longer, so we loaded up Moon and went for a drive. We wandered through a couple of the state parks, and on the way, passed this interesting house.

I don’t know that I’d want to live in it, but it’s… different. There’s an odd mix of housing around the Lake Lanier. You’ll see a two million dollar home sitting right next to a run-down trailer. Expensive houses that look like crap, and older homes that are beautifully maintained.

I really like the rock on this one, and the arch is interesting. It’s on a large lot, and has a nice wrought iron fence around. Visually, it’s one of the more striking homes in the area, compared to the usual nouveau-rich tacky overdone stucco house with 200 roof lines, and the obligatory Hummer H3 pickup truck in the garage.

If I get back by and find the address, I’m going to look up the value of the house in the GIS tax database. This lot doesn’t appear to have lake access, so it’s worth less than one that does. On the other hand, it’s a good sized parcel, and a large house.