After getting my CP back in January, I’ve finally gotten to put it to good use: in our old churches back parking yard. My mother also has, for lack of being able to spell the Italian word coming to mind, I’ll just describe as having gained injured nerves >_>.

I’ve known the theorem and mechanics of driving since I was like eight or nine, so my focal point is on filling the experience gap. Ma has been driving the same ’93 F.O.R.D. for almost as many years as its been off the assembly line, and knows its handling inside and out; I don’t. Unlike my mother however, I can trivially calculate the distance between the car and what’s around it, stuff like that is a skill I’ve developed over the years, I can both feel it and fill the missing picture in, based on what my mind has already seen. Thus getting to close to the curbing means either I miscalculated the difference between the steering wheel, and the actual wheels current vectors, or it took to long for my foot to shift between pedals: not that I can’t see where I’m going 8=). Towards the beginning, I had to threaten my mother to shut up and stop grabbing at my arm, or I would retaliate either by (intentionally) taking the car over the curb, or make her stand outside and watch. I don’t give a fuck if there’s more racket going on then in a warzone, jabber all you like, but don’t interfere! Geeze I’m not an idiot, I know better to go over the curb; and that stopped as soon as she stopped jacking the wheel towards the curbing, whenever the car got too close. See, don’t bother me, and things get done properly -.-

My mother is insanely short, and to narrow minded to assume others have the same visual problems that induces. What can I say, when I first sat down in the drivers seat I nearly knocked my glasses off, and had my head angled funny, just to avoid cracking it on the ceiling… and I’m vertically challenged myself. Just getting the seat and steering wheel adjusted was a feat, involving suspending myself over the cleaning supplies in back, in order to clear to crap out of the way so the seat would have somewhere to slide back to, and then trying to extricate myself, without castration, broken legs, or a sliced open belly. It felt like hanging myself from the cars interior roof, and applying a spiders agility lol.

The area I had for practice, is just two sets of parking spaces several car lengths long, joined by very tight turns on either end. Small enough to require paying close attention, yet empty enough to only have to worry about one parked car, hehe. Did several dozen laps around the yard over an hours time, including a K-turn to go about the other way. Started out going at the engines idle speed, before studying how she handles under different patterns of acceleration and breaking; I doubt if a claustrophobic amount of practice space in is a good thing for a noob, but I never the less, take it scientifically. For me, it is very important to learn how the vehicle handles, because I’m not going to be responsible for taking it on the road, unless I know it well enough to keep the damn thing under control. I’m crazy, but I’m not suicidal :-P.

Three things that I noticed about the family Ford: the old accelerator has a hair thin trigger, it’s got a fat arse when it comes to rate of angle change in reverse, and exactly like in dreams that I’ve had about driving, the car will move forward even with foot off the accelerator. After 16-17 years of reading the dashboard sticker that says, “To shift from park, depress break pedal” in English and French, I of course remembered to do that without hesitation. I could probably understand the thing in spoken French by now o/.

Unlike my brother many moons ago, I opted to keep things under tight control while practising. Heh, I can still remember when Reese got his learners, and ended up zipping around a large Sports Authority parking lot like a bat out of hell. At least, I was seat belted into the rear drivers side seat, and spent most of his learning sessions being plastered against the rear passenger side window, lol.

Now the big question, is how many months will it take before I get more time to practice o/.

This weekends multi-part plan

  1. shave off the moustache and company; done
  2. get a hair cut; hopefully sorted before Monday
  3. a long shower; done as soon as the mops and laundry gtfomw
  4. finish pc-bsd v8 review
  5. report Stargellas sysio code to windows; stupid rsync screw overs…
With luck by Monday, I’ll both feel less like Chewbacca the Wookie and have a lot of work done, hehe.

Bug smashing on the stack, hehe

Ok, I’ve spent some time longer then expected working on my games net code, mostly because I both needed one nights sleep this week, and wanted proper IPv4/IPv6 support going on. Sunday I basically finished principal work on the net module, and completed a pair of test cases: a really simple client and server program. After that went smooth, I had planned to complete the finishing touches.

The problem: the server example segfaulted. Now those who know me, I consider it a plight upon my honour as a programmer, for any code that I’ve written to crash without due cause (i.e. not my fault). So I spent work on Monday taking a break: refining code quality and then porting it from unix to windows. During the nights final testing runs after that however, I had not solved the mysterious crash yet, and got the same results. I switched over to my laptop and recompiled with debugging symbols, only to find that my program worked as normal, only dying with a segmentation violation once main() had completed, and the programs shutdown now “Beyond” my control.

My first thought of course, was “Fuck, I’ve probably screwed my stack”[1], a quick Google suggested I was right. I also noted that turning on GCCs stack protection option prevented the crash, so did manually adding a pointer to about 5 bytes of extra character data to the stack. Everything to me, looked like the the return address from main was being clobbered, or imagine invoking a buggy function that tries to return to somewhere other then where you called it from. Before going to bed, I narrowed it down to the interface for accept(). Further testing showed that omitting the request for data and just claiming the new socket descriptor, caused the crash to end but still, some funky problems with an invalid socket. Inspection of the operation also showed that the changes were well within the buffers boundary, yet it as still causing the crash. So I finished the remaining stuff (i.e. free()ing memory) and went to bed.

Having failed to figure it out this afternoon, and starting to get quite drowsy, I played a trump card and installed Valgrind. It’s one of those uber sexy tools you dream of like driving a Ferrari, but don’t always find a way to get a hold of lol. For developers in general, I would say that Valgrind is the closet thing to a killer app for Linux developers, as you are ever going to get. In my problem case however, Valgrind wasn’t able to reveal the source of the problem, only that the problem was indeed, writing to memory it I shouldn’t be screwing with o/.

So putting down Valgrind and GDB, and turning to my favourite debugging tool: the human mind. It was like someone threw on the lights, once I saw the problem. Man, it’s wonderful what a good nights sleep can do!

Many data structures in Stargella are intentionally designed so that they can be allocated on the stack or heap as needed, in order to conserve on unnecessary dynamic memory allocation overhead, in so far as is possible. So the example server/client code, of course allocated its per socket data structures right inside main(). Because there is no real promise of source level compatibility between systems, the networking module is implemented as a header file, having function prototypes and a data structure representing a socket; which contains an opaque pointer to implementation specific details, itself defined in unix.c and windows.c, along with the actual implementations of the network functions. Because of that,the behaviour of accept() can’t be emulated. Net_Accept() takes two pointers as parameters, first to a socket that has been through Net_Listen(), and secondly to another socket that will be initialised with the new connection, and Net_Accept() then returns an appropriate boolean value.

All the stuff interesting to the operating systems sockets API, is accessed through that aforementioned  pointer, e.g s->sock->whatever. What was the big all flugging problem? The mock up of Net_Accept(), was originally written to just return the file descriptor from accept(), allowing me to make sure that Net_Listen() actually worked correctly. Then I adjusted it to handle setting up the data of the new socket, in order to test the IPv4/IPv6 indifference and rewrite the client/server examples using Net_Send() and Net_Recv(), and that’s when the crashes started.

I forgot to allocate memory for the sub structure before writing to the fields in it, resulting in some nasty results. When I say that I don’t mind manual memory management, I forget to mention, that programming while deprived of sleep, is never a good idea, with or without garbage collection ^_^.

Now that the net code is virtually complete, I can hook it into my Raven Shield server admin tool, which will make sure to iron out any missing kinks, before it gets committed to my game. Hehehe.