Category Archives: Life

Minecraft image set #3

Inspired by my brother’s pig farm I built my own industrial ranch.

The sheep side

 

The cattle side

 

In minecraft you can breed animals with only two pieces of wheat. Since we have an industrial wheat farm it only makes sense to build an industrial cattle and sheep ranch.

Initial sheep population

Final sheep population

Final cow population

With so many sheep you can jump into the pen, fling the shears around like a wild man and come out with enough wool to build several houses. If you stay at it and keep the herd sheared you’ll soon have too much wool.

For very large values of too much.

In my case it was enough to build an inverted pyramid house.

An inverted pyramid made of wool

The pyramid is four stories high with an interior so plain I had to remove one of the floors to keep things interesting.

It has a nice view of the farm as well

Language that does not complain -> confusing bugs

Today I had to debug a clients site.

You see, the slider was broken.

Why?

The slider javascript wasn’t being loaded.

Why?

The entire lower portion of the html is non-existent.

Even the caching plugin’s status information is missing.

The html’s last words were “<!– mfunc”, a harmless comment. Let’s pay attention to where the comment was.

It was where the sidebar should have been.

Let’s look in the sidebar template file.

That’s odd, the template uses a special php function that stops php from sending the html to the browser until you call a second special function.

Maybe a bug is stopping this second function from being called.

Let’s add other random comments to see if they show up.

They do. Thus it cannot be the special function.

So what is it? Lets see what the supposedly harmless comment is.

It’s magic.

Or that is to say, it is way for a plugin to run code indirectly if the site is being cached.

All added with a wordpress hook, a way for a plugin to indirectly run code during html generation.

Yes! A plugin is indirectly-indirectly running code, and this code is crashing.

And that is the real bug.

I just wish finding it was quicker.

The hardest bug I have ever encountered

This semester I’m taking a RISC assembly class. I like it.

Programming in assembly is relaxing because of its simplicity. Or at least  until it stops being simple. Such as today.

For a CRC calculating program I needed to be able to set a mask with the high bits set. This is tricky since the move instruction can only set the lower 13 bits. In my first attempt I used move and shift instructions to assemble the mask. This was of course messy which is why I was thankful when my friend showed me the set instruction which could set all 32 bits at once.

We puzzled at how this might be possible since that would leave no room for the opcode. The entire instruction has to be translated to 32 bits which includes the arguments to the instruction. So 32 bits of instructions should be impossible.

I decided to ignore the underlining mechanise.

Turns out ignoring what the computer is doing when you are programming in assembly is a bad idea. The set instruction does in-fact map to multiple instructions when the input is greater than 13 bits.

It just so happens that I would find this out the hard way. You see one of those high bit masks I needed was assigned in the delay slot of a branching instruction. For the laymen; a delay slot is a way to slip in an extra instruction when otherwise the cpu would do nothing. This meant that of the two instructions that set was translated too, only one of them was ran.

Thus one key portion of my bit mask was left unset.

When the mask should have been 0x80000810 it turned into only 0x80000800

Notice that the 5th bit is a zero instead of a one and so my CRC had one less xor gate than it should have.

This easily took an hour to debug. And unlike most bugs this one didn’t have an ah-ha! moment. Even when GDB clearly showed that the mask was incorrect I had to experiment to assure myself of what I was seeing.

Assembly is not very relaxing when you do not know what the computer doing.