It’s just one of those nights….

… where I’m to restless about getting things done, yet to freaking tired to actually get anything of value done. I’ve already spent most of the day like a humming bird, even while on an RvS break; so it’s starting to get ridiculous lol.

For the past few days, I’ve been pondering ideas and looking at where I would like to be in the next ten years. Of course, getting through this year is a prerequisite 8=). I tend to analyze things systematically, so it’s a problem I engage no differently then any other, it is merely a bigger issue to study. At present Operation Redeemer is proceeding at a terribly slow pace, one that’s being forced upon me o/, and likewise data also suggests this will increase the odds of later being shafted before things conclude. Experience has shown me that families either represents the finest support system ever created, or the exact opposite: matter and anti-matter. Sadly with about the same impact on moving forward, only useful with a warp core and containment field. The principal agenda guiding my short term plans (Redeemer), is focused on brushing away the obstacles that make any larger aims, an utter impossibility. Ever being who I am inside, of course I’ve gotta lay foundation on later plans too. In the end though, only time can tell the future.

At the more immediate moment, I’m just whipped. There’s no shelter from exhaustion at this point, and probably never will be in my life: that’s one reason that I tend to take things one day at a time. I’m so fucking tired, yet hate to watch the hours go by without getting anything practical done. I also know, working on most of the stuff that needs doing, isn’t wise when I feel like passin’ out.

The crappy thing is, if I log off now, either I’ll be wide awake in a couple of hours (and back in the same boat), or by the time dawn rolls around, I’ll feel like slamming my sleep starved head into a wall, o/.

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.

My games net module is almost complete under unix, and in theory should be able to handle both IPv4 and IPv6 communication fine; not that I have much to test the latter with. Windows support will need a bit more tweaking, and then it’ll be possible to plug it into my Raven Shield admin quiet easily.

Pardoning interruptions, I’ve spent about 6 hours of my day working in straight C, followed by about 15-20 minutes for a little rest. For some sickening reason, my weekends almost always fall into the category of working all day, eating dinner, then working until dawn lol.

Doing things in C, I find more time consuming then more dynamic languages, chiefly because of how much testing I (try to) do, coupled with how much lower-level stuff one has to keep in mind. Having to deal with memory management issues, is not a problem for me, although I do admit that garbage collected languages can be very enjoyable. To be honest, I find the portability problems of doing anything interesting, to be a greater drawback then managing memory; e.g. by design Python is not very portable in comparison to C, but it more then portable enough for anything you’re likely to bump into on a PC, and can do ‘more’ with less bother, for an acceptable level of portability. They are very different languages at heart, and their designs reflect it strongly. A lot of people (including myself) call Cs portability a myth, and it is in the sense of what most people want (especially me), I doubt is possible without a more modern rendition of the language (NOT Java or C++). Where C truly excels at portability, well I reckon you’ll just have to study more assembly language to understand the value of it.

Now if only I had something better to do, then spend all my time behind a computer screen, monkeying around with GCC on one side, and MSVC on the other 8=).

A REAL HOME

A REAL HOME is a playground. Beware of the house where no
rough-housing is allowed and no cries of glee are heard.

A REAL HOME is a workshop. Pity the child who is unfamiliar with
wrenches and hammers, knitting needles, thread, screwdrivers and saws.

A REAL HOME is a forum. Honest, open discussion of life’s great
problems belongs originally and primarily in the family circle.

A REAL HOME is a secret society. Loyalty to one’s family should mean
keeping silent on things that are the family’s business and no one else’s.

A REAL HOME is cooperative. Households flourish in peace when the
interest of each is the interest of all.

A REAL HOME is a school. Many of life’s most important and lasting
lessons are learned here, both early in life and later on.

A REAL HOME is a temple, where people are loved and respected
and where life is appreciated, in the recognition that life in all its parts is
a gift of God, with our family being our personal and most precious gift.

Is your home, A REAL HOME?

Author Unknown

I wish I could answer that question without hurting anyone, myself included.

Almost a Quaketorious Victory :'(

It was a nice double that quickly turned into a massive battle, going up from last to match leader in the first couple minutes… couldn’t be racking up frags any faster if I had a nuke: I actually had greater then 2:1 K2D ratio. It’s like no matter what the other players did, BAM I was right on’em, often being involved in  3 to 8 way melees.

Ended up neck in neck with another match leader at the end, and cinched it at like the last blink of an eye by scoring like 6 frags in near perfect succession, winning the game!

Loaded up the next map and was having like the best freaking roll of my life, bodies dropping left and right. There’s something uniquely satisfying about using my SAS skills to counter the other match leaders “Mad skillz”, with great effect no less. Again neck in neck for the lead and looking like the end of this match is gonna flop in the bag in a sec…. when I got called off to clean up someone elses disgusting mess. Worse then that, because of QLs scoring system, not only does that mean I was forced to forfeit everything earned during that pwntacular frag fest, it negatively impacts my reputation for the quit.

And so, family induced as only it could ever be, ends one of the best game nights of my miserable little life. There must be some bastard in the universe, who can take a perverse pleasure in that. Odds are we’re related.

In being dragged across the grocery store yet again! I spent some time contemplating what I was thinking about last night, as I was finishing up part of my games net code. Wouldn’t it be practical, to just implement a simple Virtual File System? It would make adapting the code base to different uses easier, since pathes and I/O could then be defined through a set of VFS_routines, but on the downside, making it pluggable would push greater overhead on all those I/O routines at every use.

The zpkg, system input/output, and network modules present very similar interfaces. Main differences being that zpkg doesn’t have write support (an unneeded non-trivial feature), and seeking between positions in a socket, just doesn’t make the same sense as with local files. If a virtual file system layer was built on top of it, it would be rather easy to define a “Plugin” data structure providing the necessary function pointers as needed, and simply use a hash table to handle the mappings between paths. Of course that leads to the bugger of a look up operation o/.

Really, most of the places where it matters wouldn’t impact game play, since most I/O can be divided between startup phase, loading stuff, client/server communication, and shutdown phase; the chatter between client and server obviously being implemented directly on top of the networking module, and therefore a moot point. It would make it possible for the resource loading code to become more flexible at run time; i.e. being able to load game assets both out of zpkg files and local system files without a recompile or a  restrictive version of the VFS.

I think it would be worth while, as an added plus, it would even allow splitting the path argument to Zpkg_Open, and pulling out the interesting bits into the VFS adapter function, which would be replacing that feature of the zpkg module.

For today however, my primary goal is to port the networking code (almost) completed last night, from the BSD Sockets API over to the Windows Sockets API. That way I can replace the less appropriate network code in my RvS admin program with it, and save having to complicate its design to make the most of Qts networking API. All while improving my games code base ^_^.

Although WinSock was based on the old Berkeley interface, Winsock has arguably grown more over the last decade, then the Unix interface has over the last 20 years. Not that there was much need beyond adding IPv6 capability, which the common Unix interface already grew ages ago. I personally dislike both the Berkeley and Windows interfaces immensely, why? Because in my humble opinion, the proper way would have been something like:

int s;

if (s = open("/net/tcp/host:port", O_CREAT | O_RDRW | O_EXLOCK)) == -1) {
perror("Unable to open a connection to host:port");
}

/* do usual stuff here, like read() or write() */



where /net would be an arbitrary mount point for a special file system, in which file system operations reflect their corresponding network operations. Flags for system calls like open() and fcntl() could have been suitably extended to cope, and others like accept() implemented as needed. In the light of things like FUSE, it would be even more interesting to do it that way today, then it would have been in the 1980s.

Instead of that simple form, whenever we want to create a socket: we have to setup suitable socket-specific data structures, which and how many depending on the operations to be conducted; common practice is to zero over the most important (sockaddr_in / sockaddr_in6) structures before using them, and leave it to the compilers optimizer whether it actually happens at run time; look up in the system manuals what pre processor definitions correspond to type of network connection we want (let’s say TCP over IP) for the socket() call; initialise the field structures, using the same pre pre processor flags, and even converting details like the port # into suitable formats, all by ourselves. After which we might finally get around to doing the socket I/O ourselves, pardoning any intervening system calls needed for your particular task.

/*
 * Assumes open flags in previous theoretical example corresponded to a connect
 * operation, rather then a bind() and listen() operation. Like wise for the
* sake of terseness, I'm "Skipping" support for real.host.names rather then IPs.
 */

int s;
struct sockaddr_in addr;

memset(&addr, 0, sizeof(struct sockaddr_in));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if (inet_pton(AF_INET, "xxx.xxx.xxx.xxx", &addr.sin_addr) != 1) {
/* handle AF_INET, address parsing, or unknown errors here.
* error is indicated by return value.
*/
return;
}

if ((s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
perror("Unable to create socket");
goto CLEANUP;
}
/* use system calls and a data structures as needed to setup things as desired */

if (connect(s, (const struct sockaddr *)&addr,
   sizeof(struct sockaddr_in)) == -1)
{
perror("Unable to connect socket");
goto CLEANUP;
}

/* do I/O here: send/recev, or read/write */

CLEANUP:
shutdown(s, SHUT_RDWR);
close(s);

I reckon the Berkeley interface was the right choice, for portability between systems (including non-unix ones; making it easy to write stuff like WinSock), and probably easier to graft onto the 4.3BSD kernel, but it’s damn inconvenient for a UNIX programmer. That ain’t changed after about 25-30 years.

Oh wells, at least it works pretty darn near every where, give or take a few kinks.

Now playing: one of my favourite songs

I don’t want another heartbreak
I don’t need another turn to cry, no
I don’t want to learn the hard way
Baby, hello, oh no, goodbye
But you got me like a rocket
Shooting straight across the sky

It’ s the way you love me
It’s a feeling like this
It’s centripetal motion
It’s perpetual bliss
It’s that pivotal moment
It’s, ah, impossible
This kiss, this kiss, unstoppable
This kiss, this kiss

Cinderella said to Snow White
“How does love get so off course, oh
All I wanted was a white knight
With a good heart, soft touch, fast horse
Ride me off into the sunset
Baby I’m forever yours”

It’s the way you love me
It’s a feeling like this
It’s centripetal motion
It’s perpetual bliss
It’s that pivotal moment
It’s, ah unthinkable
This kiss, this kiss, unsinkable
This kiss, this kiss

You can kiss me in the moonlight
On the rooftop under the sky, oh
You can kiss me with the windows open
While the rain comes pouring inside, oh
Kiss me in sweet slow motion
Let’s let everything slide
You got me floating, you got me flying

It’s the way you love me
It’s a feeling like this
It’s centripetal motion
It’s perpetual bliss
It’s that pivotal moment
It’s, ah, subliminal
This kiss, this kiss, it’s criminal
This kiss, this kiss

It’s the way you love me, baby
It’s the way you love me, darlin’, yeah

It’s the way you love me
It’s a feeling like this
It’s centripetal motion
It’s perpetual bliss
It’s that pivotal moment
It’s, ah subliminal
This kiss, this kiss, it’s criminal
This kiss, this kiss

It’s the way you love me baby
It’s the way you love me darlin’, yeah

This Kiss—Faith Hill

Yes, in some ways I’m a bit hopeless at heart lol.