< September 2006 >
      1 2
3 4 5 6 7 8 9
Wed, 20 Sep 2006:

Currently, I am totally struggling with APC's shm memory. Usually with most memory issues, the system cleanly segfaults. But when the memory is part of a 128 MB mmap() area, a couple of bytes here or there show up way too late in the debug operations to detect and fix.

Now, a lot of the allocator code has things which allocate n bytes + sizeof(header) and return the allocated area - sizeof(header). The problem is that my previous watchpoints code cannot differentiate between these two, unless I put an explicit watchpoint on the location. Not to mention, it has no concept of free operation in conjuction with the original block.

Digging around in valgrind code, I found an elegant answer to the problem - VALGRIND_MALLOCLIKE_BLOCK and VALGRIND_MAKE_NOACCESS. Here's a mocked up version of my code, which seems to work out.

#include <valgrind/valgrind.h>
#include <valgrind/memcheck.h>

void *  alloc(size_t n) 
	void* x = malloc(n + 42);
	x = (unsigned char *)x + 42;
	return x;
void dealloc(void * ptr)
	free(ptr - 42);
int main() 
	size_t n = 200;
	char * a = alloc(n);
	a[0] = '1';
	a[-1] = 'x';

Now, the valgrind has red-zones, which are like canaries or sentinels for memory over-writes. I haven't figured out quite how to use them, but this should be enough right now, I think.

==28706== Invalid write of size 1
==28706==    at 0x80484ED: main (x.c:23)
==28706==  Address 0x4025051 is 41 bytes inside a block of size 242 alloc'd

And the line 23 is the a[-1]. Valgrind is just amazing. Ever since I've hit up on this tool, I've found that my debugging life is a lot easier. Now, to reproduce original bug and nail that son of a b*tch :)

They separate the right from the left, the man from the woman, the plant from the animal,
the sun from the moon. They only want to count to two.
                -- Emma Bull, "Bone Dance

posted at: 15:44 | path: /hacks | permalink | Tags: ,

Last weekend, I was holed up in Delhi attending (and giving a talk) at Freedel. I had given a talk at Freedel 2005 , which generally swooshed over everybody's head and left me disappointed. So this time, I'd picked a dead easy topic which I couldn't miss with - gimp plugins.

Me and premshree arrived there in an evening flight. I had picked the 4 PM flight, so that I could see the sunset from the flight and it was just to die for. To see the clouds outlined by the red borders of golden sunlight, was quite a sight. We were missing our mini cameras, unable to load up the big Nikon while flying. But let us forget the trip and focus on the take-homes from the conferences. Here are a few.

* inside airport
Premshree: Man, Delhi women are *hot*

* few minutes later, outside
Premshree: Shit, Delhi is *hot*

And yes, it was hot & humid.

FUNK: And a new keyword was born, been a while since Awesomeness. Now the latest cool (I mean, funk) word to say is - Funk. It has become literally the new F-word. All thanks to Premshree's diligent effort at shoe horning this word into any sentence in need for wordless words. So the whole funk conference was the total funk.

Then we had a couple of memorable quotes from cray3. The first one being the polite motto ("STFU, please") on her laptop as well as the "The daemons are no longer just in my head". But the "We will not be serving snakes on this plane" deserves first prize for the hinglish accent jokes.

Me and Premshree were staying at Kishore's place. And during a l33tness war during the party at OldMonk's place, Kishore won a few brownie points by asking - "And tcpdump is your mail client ?". Short of pissing off the organizers, we'd pulled off a GNUnify, topping the "Our sysadmin is a cron-job" by a few heads. OldMonk had a couple of quotes to his name as well, but I'll desist from mentioning them in such polite circles - very apt, but truly OldMonk.

And for the very first time, the audience clapped when my demo worked, rather than the respectful silence I'd been used to. So all in all, I'm glad to have talked ... I mean, funked out at this conference. Next year, it is going to be in Feb, which should prove to be cooler and even more funkier :).


Take my advice, take the next flight,
And grow some funk, grow your funk at home.
                -- Elton John, "Grow Some Funk of Your Own"

posted at: 09:22 | path: /conferences | permalink | Tags: , ,

One of the lamest hacks, we've ever done is something called Debt-o-Matic. I know spo0nman has already blogged about this, but there's more to this hack than meets the eye. To start with, this was the first hack which went from decision to action in around twenty minutes. And then we *designed*.

Through out this period, I was being active and generally bouncing around. Sad to say, but I was the product manager for the hack - doing little and suggesting a lot. But I redeemed myself by producing a kick-ass logo for for our hack. And after all that, we finally had ourselves a product before the morning dawned and an idea left to finish.

Remember the good old days in college where we used to adjust debts by transferring debts around ? We wrote up something which would find circles of debt and remove the smallest amount from all of them, by virtually circulating it. Not rocket science, but useful as this system can do it automatically. But stating privacy concerns, we cut down that to a A -> B -> C scenario, which is trimmed into an A -> C scenario.

We never got around to building the audit trail and details view stuff because it was getting late for our flight to Delhi. And off we went, leaving teemus to submit the hack, but there still was nobody to present it.

In short, we had fun.

Forgetfulness, n.:
        A gift of God bestowed upon debtors in compensation for their destitution of conscience.

posted at: 00:42 | path: /yblr | permalink | Tags: , ,