< May 2006 >
SuMoTuWeThFrSa
  1 2 3 4 5 6
7 8 910111213
14151617181920
21222324252627
28293031   
Mon, 29 May 2006:

People are sheep. They move in herds, believe in numbers (look at democracy) and avoid solving anything in person. This is, contrary to common sense, perfectly normal and how the world should be - read it through and then let me know, if you think otherwise. Before I can explain to you exactly why people are so timid, I'd have to explain why the Original Hero in our particular story wasn't the Go-Getter Hollywood crafts its dreams around. And it all starts out pretty normally [1].

So, I'm sitting around at my parents', munching on some easily munchables in front of the idiot box. Tuned in at the moment is one of the new cartoon channels which is reinventing Tarzan for the youngster of today. So there you see Tarzan telling his ape friends that the new evil leader (complete with silver back, huge fangs and red eyes) is weaker than the entire family combined. After hearing that motivational speech from somebody hanging upside down from the arms of the giant ape, the entire family drives the bullying big male out. And they all lived happily ever after, at least until the next episode.

Now, to pick out where this particular story diverges from stated 'real' world into a more fictional human world. But first, I want you to marvel at the sophistication of the tool at my disposal now - language. Sure, a cat call in the night or a howl in the distance is communication too. But our chatter possesses something unique in itself. We talk about things that could be - we talk about the future as if it were real. The first time your mother told you don't do that, or else $bad_thing_could_happen.... was when you were introduced to the very possibility (that word itself speaks volumes) of things that could be. In other words, the animals could understand what could be done if they joined forces.

Now, human society is very peaceful compared a lot of other social mammals. In almost every other primate society there is a lot of bullying and fighting at lower levels than the alpha males. Even in a stable society there are always some murmurs of disapproval and fights happen in the background. So what's different in our world that stops this from happening ? While I ponder about such important questions an advertisement for clean teeth (uhmm... I mean toothpaste) pops up.

*CLICK*. Yet another soap on some other channel. *CLICK*. Same story of a family broken by something. *CLICK*. Ah, it's a veritable cat fight between two women with bindis large enough to cover Switzerland (you *know* that I stole that analogy). Oh wait, they're just stopping at name calling. I guess language comes up as a winner yet again in this story - so where are the sheep people that I started talking about ?

Language is merely the tool. You might think the real clincher in the deal is how language helped organize things (like the Tower of Babel for instance). Well, before mankind was big enough to start dividing ourselves over language, religion, caste and creed, we lived in tribes. The organization there needed to kick some ass more than the mot juste and language was hardly (yet) the way to get your average cave-woman interested.

Even with philosophy running in parallel, daytime soaps are boring. *CLICK*. Oh, its some mafia gangster flick and some guy's getting shot because he ratted out some 'brother' to de cops. And he did that because the other guy made eyes at his sister. Seems fair, I think. If I were in the same posish, I'd be wiping the blood off my knuckles too. Wait, he didn't stand up and fight, he merely went to the Big Brother and squealed like the family pig (George Orwell is a genius). Language has its advantages for the weak and oppressed.

But didn't evolution stick up for the 'Fittest' or something ? So, if you are weak and oppressed, you'd do good to the species to stay out of the gene pool. Then why does human society discourage bullying and stick up for a very unnatural concept called fair play. Because long back during the dark ages of human evolution, language helped the weak to team up and beat up the bullies. That's just a prediction and this movie's getting way too bloody to have a happy ending.

*CLICK*. It's one of the 24x7 news channels and it's showing a strike in some factory plant somewhere. The union is demanding special protective masks and compensations to the families of its employees who have succumbed to halitosis. The basic co-operative skills mankind developed in the distant past for hunting large animals of the last ice age have been subverted to bring a factory to a grinding halt. On the other hand, the weak worker class have no way to fight the system other than uniting. And it looks like they're coming out winners.

The critical combination of language and co-operation form a very sharp tool in the arsenal of the weak and the timid. The call goes out - All for one and one for all. Such coalitions and brotherhoods must have picked off every one of the stereotypical aggressive alpha males when the species was passed through an evolutionary pressure like a famine or disease. Of course, you can't blame the mob - dying out was hardly a worthy choice. The badass alpha male just didn't Fit in with the times of crisis.

Even today, our society runs on the basis that its combined might is significantly bigger than is in possession of any one individual. This is why democracy is so popular, because aggressive individuals do not survive in a majority of their own - this town isn't big enough for the both of us. But we still need the risk taker, adventurer and explorer - they deny society and are labeled mavericks, become recluses in old age. You know the examples. We're not like them, as much as we admire them.

Still, somewhere in our primitive brains, we crave for an absolute leader to settle our disputes, punish the wicked and reward the good deeds. The all powerful, ape lord of our own tribe, that we used to see and obey everyday in those dark and distant days when we had hardly climbed down from the trees. We worship him, live our days in awe of his awesome power, sleep nights under his protection and follow him across hades if necessary. Oh, my God, what am I talking about ? (*heh).

Us humans, we are such a coalition of the timid, where decisions are by consensus and where politeness overrides correctness. That's the way it is and short of mass genocide there's nothing you can do to fix it. So quit cribbing.

  [1] - Nothing except loud music or talking women seem to snap my brain out of overdrive.

--
Let the meek inherit the earth -- they had it coming.

posted at: 12:09 | path: /philosophy | permalink | Tags: , ,

Last night, I was attempting to build Flubox-0.1.14 on my home amd64 box. After struggling with a couple of errors in src/Resource.hh I managed to get it built with gcc-3.4.2. Now the real bug hunting started in earnest. So consider the following code.

void va_arg_test(const char * pattern, ...) 
{
    va_list va;
    int i = 0;
    const char *p;

    va_start(va,pattern);
    while((p = va_arg(va, char *)) != 0) {
        printf("%02d) '%s'\n", ++i, p);
    }
    va_end(va);
}

int main(int argc, char * argv[])
{
    va_arg_test("wvZX", "hello", "world", 0);
}

Now, to the inexperienced eye it might look like perfect working code. But the code above is buggy. If I wanted to really fix it, I'd have to rewrite it so.

    va_arg_test("wvZX", "hello", "world", NULL);

The old code pushes 2 pointers and an integer into the stack as variable args, while it reads out 3 pointers inside the loop. In normal x86 land that's not a big deal because pointers are integers and vice versa. But my box is an amd64, there LLP64 holds sway. A pointer is a long long, not just a long. So it reads 32 bits of junk along with the last 0 and goes on reading junk off the stack.

If you'd run my so called buggy code on an amd64, you'd have found that it doesn't actually crash at all. That's where the plot thickens. To understand why it doesn't crash, you have to peer deep into the AMD64 ABI for function calls. As far as I remember, the ABI says that the first 6 arguments can be passed to a function using registers. So the current assembly listing for my code shows up as

    movl    $0, %ecx
    movl    $.LC1, %edx
    movl    $.LC2, %esi
    movl    $.LC3, %edi
    movl    $0, %eax
    call    va_arg_test

But if I increase the arguments to 8 parameters, then the data has to be pushed into the stack to passed around and then you'll note the critical difference in the opcodes between a pointer and integer handling.

    movl    $0, 16(%rsp)
    movq    $.LC7, 8(%rsp)
    movq    $.LC8, (%rsp)
    movl    $.LC4, %r9d
    ...
    movl    $0, %eax
    call    va_arg_test

As you can see the integer 0 is moved into the stack using the movl while the pointers were moved in using the movq viz long word and quad word. Doing this for varargs on amd64 leaves the rest of the quad word in that stack slot unitialized. Therefore you are not guarunteed a NULL pointer if you read that data out as a char *.

After that was fixed in XmbFontImp.cc, fluxbox started working. God knows how many other places has similar code that will break similarly.

--
At this rate you'd be dead and buried before that counter rolls over back to zero.
Better get some exercise if you want to fix it when it happens.

posted at: 10:11 | path: /hacks | permalink | Tags: , ,