February 27, 2010
Pascal's Paradox
A few days ago, a funny Seventh Day Adventist showed up on my door. He was a friendly enough fellow, and asked about my faith. "Atheist," I said, "and anyone that tries to tell me otherwise is probably trying to sell something."
Yeah, I like the Princess Bride. He scribbled this down in his notebook. Great, I'm probably on some kind of "prayer list" or something.
"Really?", he asked. "How can all of this subjective experience be just nothing?"
"Simple," I said, "I live my life, and then I die, and then there is nothing left to experience."
"What do you think Jesus was: son of god, historical figure, or work of fiction?"
"Probably a historical figure, but fiction seems more plausible at times."
"Well what about the objective reality?"
Obviously my time in government service left me entirely too...sober. I was growing impatient. "Look," I said, "I go through life and question every piece of information that gets thrown in front me. I don't win a lot of friends, but I do make a difference."
"You're familiar with Pascal's Wager?" he asked
Yeah, Pascal's Wager. I could use the official church jargon to explain why it is a retarded bet, akin to playing Russian Roulette (it's also a lot less exciting than Russian Roulette, I imagine). Instead, I argued with reason. "Religious people waste their entire lives praying and bowing and hoping things will happen. I make things happen, because I know that only people can make things happen. That is the fallacy of Pascal. Hope."
So today, I put my money where my mouth is. One of Laura's co-workers, Pablo, is from Chilé. His brother lives in a small town outside of Concepcion, as close to the epicenter of today's quake as possible. Pablo can't reach anyone in his family (most of his family lives near Santiago). I decided to donate my last paycheck to the Red Cross. Yeah, I probably can't afford it right now. I'm no saint, either. But money, more than prayers (or even yoga mats), is what folks in Haiti and Chile need right now.
Green Hills C Compiler bug
I had a rather proud moment a few days ago. I had been looking at a curious piece of compiled code that had an integer promotion bug. Yeah, I have some pretty weird hobbies these days. This particular bug was for the Motorola Coldfire processor. The C code, it turns out, looked like this:
unsigned char table[256] = {0xsomevals} // global array, located on process heapThe compiler compiled the code (the function part of the above) into something like this:
unsigned char array_lookup(unsigned char uc){
return table[(unsigned integer) uc];
}
link a6, #0
;; there would be a 'store registers' command here', I don't remember the syntax at the moment
;; stw.l (a0,d0), (-sp) ?
move.l -4(sp),d0
mvs.b d0,d0 ;; offending line
move.l (0,d0+a0),d0
unlink a6, #0
;; there would be a 'restore register' command here, again I don't remember syntax
rts
For the coldfire assembler unaware, the mvs operation is "move with sign extension". The effect is that the function can return memory logically *before* the array. If the unsigned char passed in is 0x80 or greater, the most significant bit of the byte is a '1'. The sign-extended move operation makes the index value negative. What is interesting here is that the compiler ignored the explicit unsigned integer cast when it dereferenced the element in the array.
It turns out that this was a bug in an older version of the Green Hills compiler. Newer versions don't exhibit this erroneous behavior. I have no information on what versions of the Green Hills compiler are affected by the bug, but if you are a vendor programming Coldfire V4 cpus (mvs was introduced in the Coldfire V4 instruction set), you may want to compile my above code snippet and make sure that your compiler is not affected.
I have to say that I was kind of impressed with myself for finding the bug. The people that produced the compiled code were kind of dumbfounded as to how I stumbled upon it. Since I have started exploring embedded systems security, I've decided that the C language is probably one of the most wretched things in the universe, and that embedded system vendors ought to use as much as peer-reviewed code (read: open source) as possible in their systems. Here I mean both compilers and process code. C compilers for these systems generally don't receive as much scrutiny as desktop application compilers, probably because the target processors are not x86.
February 13, 2010
Hacking Traffic Signals
I noticed something funny on my walk tonight. The traffic signals in Pullman are timed funny for pedestrians.
I've always lamented how horrible "downtown" Pullman is for pedestrian traffic. Smash a crosswalk button and you often have to wait for 5 minutes for the lights to change. Most of our intersections have traffic flow sensors on the signals (cheesy little things, I honestly have no idea how they work). I sat at one intersection and tried a few experiments to see how the traffic flow affected crosswalk time.
Experiment 1: Hit the button while traffic is flowing steadily through the intersection. Time to light change (and my 'walk' sign lighting up): 3:30.
Experiment 2: Hit the button while one car is going through the intersection. Little to no traffic following this car (two more cars went through the entire time I waited for this change): 3:30.
Experiment 3: Hit the button while no traffic was flowing through the intersection. There was a ten second gap in traffic. The light changed in 0:15.
Conclusion: The traffic algorithm at this particular intersection is retarded. It must measure traffic flow at the moment the 'walk' button is hit, and decide how long to wait based on that single measurement. As a pedestrian, you should wait until there is a small break in traffic to hit the walk button. You'll probably save time by not hitting the crosswalk button right away...
December 27, 2009
Lolo Pass
On this trip, I joked that Jesus must hate me for being an atheist. Things did not go exactly as planned...
Laura and I rented a cabin in Lochsa Lodge, a cozy little 200 square foot ordeal with a nice wood-burning stove for about $40 a night (more expensive due to the holidays). The lodge is about an hour and change west of Missoula, Montana, and only about fifteen minutes away from Lolo Pass, a wonderful little backcountry skiing area. What an hour it can be where Missoula is concerned...
We headed up on Christmas Day, and went straight to the Pass to do a little skiing. We arrived with not a whole lot of sunlight left. After getting the heart going and doing a few turns, it was time to check in to our cabin.
When we arrived at the Lodge, I got out to hear a very definite leaking sound from one of my rear tires. "No problem," I thought, "I have a full-sized spare." Some story from my mom's boyfriend, Jack, came to mind almost immediately. When I first drove home with the Volkswagen (back in 2006 I guess), he said, "Oh man, I hated my Audi. One time, I got a flat tire, and the wheel had this stupid special bolt on it that I couldn't get off."
You could imagine where this is going. It turns out that my VW also has a "security nut" on the wheel, which requires a special adapter to remove. Unfortunately, while moving, I mistook said special adapter for a bicycle tool and put it in my bicycle repair box. Doubly unfortunately, I don't bring my bicycle repair box with me when I go skiing very often.
Without the tool, it was impossible to remove the wheel. The friendly folks at Lochsa Lodge loaned me a portable air compressor. With it, I was able to drive to Missoula on Saturday. I was greeted in Montana by a nice piece of gravel hitting the windshield, putting a good-sized crack squarely in the center.
The VW dealer in Missoula could not locate the special tool that I needed, two auto parts store and a tire store said they were unable to remove the wheel as well. Eventually, I talked Les Schwabe Tire into trying, and they were, at least, able to get it off and patch my tire.
Another unfortunate event was noticed on the ride home. My other rear tire had developed a leak. This one wasn't as quick (a few hours from fully inflated until flat, I supposed), so I decided to worry about it later.
Saturday was more or less shot for skiing. We opted to go to Jerry Johnson hot springs instead. Jerry Johnson is without a doubt the finest spring I have visited. The pools are deep, hot, silt-free, and not so backcountry that you freeze on the way back to the car. This last bit has one sad side-effect -- bathing suits are more-or-less required.
Sadly this trip was just not going to go my way. I managed to jump onto an ice-covered rock while navigating the springs by moonlight, and landed squarely on my chin. It is my reward to nurse a nice gash for the week. Mayhaps I'll gain a nice scar from it. I hear women love those...
I managed to squeak back on my bad tire. It had perhaps 2 pounds of air left when I rolled into Pullman (and my what a drag that makes on the old fuel economy). I guess I'll take this as the same sort of sign that I treat flats on my bicycles -- time to get new tires all around. It's sad, as they have tread left. They're just dry-rotted from lack of use...
November 22, 2009
Snow Falling on Tamarack Pine
We're in the middle of our first real snowfall of the season. In town, we might get three or four inches. Moscow Mountain is just a 20 mile drive from here, and goes up about 2500 feet above the town's elevation. That short distance makes all the difference in the world where winter weather is concerned.
Laura, Jeff (a caving/rock climbing/mountain biking/backpacking all-star, and professor at the U. of I.) hiked up Moscow Mountain. It started as a stroll up a fire road near Cabin Trail, where I often mountain bike. A ways up, the snow started getting deeper, the wind started howling, and the snow started dumping. We walked across the "main face" of the mountain (it can often be seen as a big white field from Moscow and Pullman) where the snow was 2-3 feet deep in most places, the wind blowing ice pellets in our eyes at 20-30mph. We took a little respite from the wind in an abandoned mine, maybe 30 feet below the very top of the mountain.
The top was pretty snazzy, with some tattered and torn mountain flags. I'm told it would have a hell of a view, except that we couldn't see much more than 30 feet in front of us. The way down was also fairly harsh -- easier to hike without glasses on then with them (my glasses kept fogging, and then icing up, making it pretty hard to see). I can't say that I've done such a fun hike in a while. Soon, I've promised myself a set of backcountry skis, so I can hike up this local mountain and have a ball coming down it on something besides a mountain bike.








by reid
on November 23, 2009

by reid
on April 16, 2009
