I guess I'm a C++ novice. I'm certainly not a C++ expert. Every now and again I figure out a problem that makes me stop and wonder how I never learned this before. (Or possibly, why I didn't remember this when I learned it before.)
I'm take a graph theory class. It's been a lot of fun. Graph theory really isn't too difficult so long as you aren't afraid of lots of pointers and dynamic memory allocation. For homework, I had the option of using C or C++, so I chose C++ to keep everything beautiful. Well, almost beautiful. This is C++, after all.
I was plugging away on my homework when I got one of those dreaded "segfaults". As per my usual habit of diagnosing pointer problems, I started littering my code with asserts and then used ddd (my favorite debugger GUI) to see what's going on when the asserts fail. In the process, I discovered a better way...at least for memory and pointer issues: Electric Fence and valgrind.
Electric fence helps you find memory problems by stopping the program in it's tracks when pointers and deallocation run amuck--as opposed to letting the program run just fine until you get "lucky" and a pointer finally does something bad enough to bring the program to a screeching halt. It's one of those tools I'd heard about and never got around to using because I thought it would be complicated. Ha! It's not even close to complicated. To use it, simply compile like so "gcc -o my_prog my_prog.cpp -u malloc -lefence" and run your program. Note how electric fence replaces the malloc library.
Valgrind gives you a running tally of the cumulative evil of your program and halts the program if necessary. I found valgrind more helpful than electric fence because of it's verboseness. (Electric fence gives you about as much information as "your program is bad, fix it.") Another plus for valgrind is that you don't have to link against it, you just have valgrind launch your program like so: "valgrind --tool=memcheck --leak-check=yes my_prog".
In the end, what was my problem? The first problem I had was not initializing a pointer to NULL and then assuming it was NULL later on (oops). My second problem was that I was calling "delete" (delete a single element) instead of "delete[]" (delete an array of elements). How did I not learn about "delete[]" before? I suppose it does look vauguely familiar. I guess *I'm* losing my memory now. (Yeah, yeah, bad pun.)
Now I know even *more* about C++. Mu-ha-ha-ha-ha!
Apparently Nike is partnering up with OSU's Badminton Club (a.k.a. the club here at my school) to design badminton shoes. You can read the story at the Daily Barometer. If only I had time to join. I really miss not playing since high school.
Yesterday, out of complete necessity, I spent some time drawing up my schedule for this term. The first two weeks of school have been insane, so after some advice from my graphics advisor, I started blocking out time for all the things I'm supposed to be doing. After scheduling time for classes, homework, TAing, and research, I found out that I'm supposed to be working 60 hours a week. It's going to be one long term.
The good news is that I have Sundays completely off. And when my TA load lightens, so will my schedule. I figure if I can get my TA load down to 10 hours a week, I might be able to squeeze my work time under 50 hours.
I just discovered something. I was trying to run XMMS on my media box over an SSH connection--like I have done for years--and xmms kept crashing with a "BadAccess (attempt to access private resource denied)" error. This was a new one to me. At first I thought it was related to Xorg versus XFree, but then I found the thread posted below.
Apparently, there were some security issues with X11 forwarding in SSH, so they broke backward compatability and implemented a new security model. The long and short of it is, if you really need the older forwarding model because of some misbehaving application (such as xmms), then you can use the "-Y" option instead of the "-X" option for "ssh".
Apparently I haven't run XMMS over SSH as recently as I thought I had. ;-)
http://www.cygwin.com/ml/cygwin-xfree/2004-04/msg00348.html
As I mentioned previously, I upgraded my desktop machine to Gentoo. Unfortunately, I discovered late last night that my hard drive was dying (40 GB 7200 RPM IBM drive). Fortunately, I have another 60 GB hard drive in that machine to pick up all the slack.
In the process of messing with the machine this evening to get it back up and on it's feet with the hard drive, I discovered "genlop". A great emerge log file parser that gives you all sorts of statistics on how long ebuilds took to compile and such. Very cool! For example, OpenOffice takes *forever* to compile:
Thu Dec 30 05:00:16 2004 --> app-office/openoffice-1.1.4
merge time: 6 hours, 35 minutes, and 17 seconds.
One particularly nice feature is that genlop can estimate the compile time of new versions of packages using the compile times for the versions you have installed. Great for upgrades!
Just "emerge genlop" and you'll be off and running.)
I was just adding a new account in Thunderbird when I noticed that it supports RSS feeds! I added the RSS feed for my blog and tried out the interface. I like it. I have been using straw, but it seems that development has stagnated.
After I got my media computer up and running, it was time to upgrade my desktop machine from RedHat 9 to Gentoo. I was very excited to finally migrate my last RedHat box! Other than running into one bug with the bootstrapping process, everything went quite smoothly. That is until I tried to install Xorg.
I started the Xorg compile, it ran for about 5 minutes and then just segfaulted. I went in to the build directory and restarted the compile, it picked up where it left off and plugged away just fine--for about 5 more minutes until it just segfaulted again. I was going nuts. The compile kept crashing at different times for no apparent reason. I suspected heat my be the issue--my 1.2 GHz Athlon Thunderbird makes ovens seem cold. I searched the gentoo forums just to make sure that there wasn't some other issue with Xorg. Yup, I found confirmation. Heat and bad memory are the primary causes for "segfaults" with gcc.
I had a great idea. Install distcc to spread the load around! I listed localhost as the last host in the configuration to force distcc to pawn traffic off the the other machines more. That worked beautifully. That kept the load down on my machine so I could install Xorg. Everything went along swimmingly, that is, until I tried to install OpenOffice.
The OpenOffice build didn't want to distribute. It only wanted to compile on the localhost. On top of that, the build really wanted to keep the machine's load around 3. Needless to say, I started getting "Bus Errors" and "Segmentation Faults". Fortunately, I had just bought a brand new CPU cooler from NewEgg. I thought I would need it for the Biostar system (I mentioned this here), but the system came with an awsome cooler. I installed the new cooler--LED's and all--and I'm off and running.
So far, so good. OpenOffice is compiling just fine and my computer has a happy green-red glow. :-D
I was at Fred Meyer the week after Christmas and they were clearing out their whole inventory of Christmas goodies. I stumbled upon a gimmicky Rudolph shaped lollipop. The stick of the lollipop was clear plastic and housed a red LED. The point of the pop is to pull out the paper tab battery guard and lick Rudolph into oblivion while the stick blinks with delight. Naturally, at 75% off, I had to buy this for Lisa.
I brought the pop home and present my cute present to Lisa with delight. She was, as usual, happy when I showed up with sugar in tow. Although, she didn't seem nearly as fascinated by the wonders of modern electronics as I was.
The next day, Lisa decided to pull the tab and eat the pop. Emily, our little distruct-o, begged to play with the stick and promptly lost the tab. I showed up from school to find a blinking lollipop stick lying around the living room. That was Thursday. It's still blinking. It's been six days. I find this somewhat disturbing. Now I'm starting to wonder if it's housing a minture camera that's recording my consumer habits.
Somwhere, in a dimly lit laboratory, a brilliant scientest was working out the perfect combinations of chemicals to produce the ultra-efficient LED. Meanwhile, a lollypop marketing "executive" was in a drunken stuper after yet another executive "brainstorming session". If only the company could just find that one product to save them from going under. And now, thanks to the blood, sweat, and tears of a scientest and a strange confluence of events know as the "captitalist soap opera," the world is perkier place. After all, what good is science if it can't make a better lollipop.
For the last 6 months or so I've been wanting to buy a little computer to dedicate to media-related stuff. I finally got around to it! I picked up a niftly little Biostar iDEQ 210V from Newegg with a Sempron 2400+ and 512 MB DDR400 RAM to go with it. I'm very pleased.
The Biostar barbones system is a great deal. I was eyeing Shuttle computers for a while, but they are pretty pricey. (Most clock in at >$200), so I settled for a $140 Biostar. Runs quiet. Looks great. Works great. The model I purchased doesn't have a TV out, so I'm using an old nVidia card with TV-out. For some reason, the VGA port on that nVidia card died, so all the colors are messed up on a monitor screen, but the TV-out works fine.
I debated about going Sempron. Since this is a media computer, I didn't need a heavy hitter like a P4 w/HT or a Athlon64. After poking around the web for a while and talking with other computer geeks, I decided a Sempron gives great bang for my buck-even with less L2 cache. I chose the lower end model (2400+) since it's plenty powerful to do what I want to do while not consuming much energy and being cheap ($75). If it seems the CPU is way more powerful than I need, I might even underclock to get a cooler, more engergy efficient system.
Now I'm in the midst of getting my Gentoo Stage 1 install up and running. Things are going very well. I think I'll have a great little media box.
So, here's the stuff I bought. Some of this is destined for my desktop machine (DVD burner, video card, CPU fan).
Biostar Barebones $139 (I bought it on sale)
AMD Sempron 2400+ $75 (I paid more than the current price.)
Kingmax DDR400 512MB RAM $65
GeForce4 MX4000 128MB w/ VGA-out, DVI-out, and TV-out $45
Rosewill DVD+/-RW w/ DVD+R dual layer support $57
Tr2tt Tr2M1 CPU Cooler $10
Yesterday was the first day of classes for winter term. It looks like it's shaping up to be a good term. I'm taking CS 520: Graph Theory with Dr. Michael J. Quinn and CS 523: Algorithms with Dr. Paul Cull. Both are great teachers, so I'm looking forward to the classes.
I'm TAing for Dr. Timothy Budd again. This is the 3rd time I've TAed for him. I'll be helping out with CS 480: Translators It will be my first TA repeat class. The very first class I TAed was Translators with Dr. Budd. It's a great class.