« April 2003 | Main | June 2003 »

May 2003 Archives

May 1, 2003

Wrapup of that last miserable day at work (Updated)

I consider to rename this Nat!'s piss and moan web journal

Just after the last update the internet router went dead, which just kind of fit into the general mood of how things were going.

Well the linker did "wing" it so I could link and build the packages. Next day on site installing the release I got hit by the problem, that some of our plists are not what the new NSPropertyListSerialization likes. Instead of giving just a warning and crunching through, Apple's programmer opted to raise an exception there. Not reading those plists would've meant a no show - not good!. So I needed to write a plist parser at the customers site to read them in and use NSPropertyListSerialization to write them out "properly" again. Then I found out that writing OpenStep files is not supported by Foundation... only just not quite as fast as I would like as I wrote something like this:


   dictionary = [NSDictionary dictionaryWithObject:@"Value"
                                            forKey:@"Key"];
   error = nil;
   data = [NSPropertyListSerialization dataFromPropertyList:dictionary
                                                     format:NSPropertyListOpenStepFormat
                                           errorDescription:&error];
   NSLog( @"what gives? %@ %@", data, error);
which yields what gives? (nil) (nil) and some head scratching. You actually need to write

   dictionary = [NSDictionary dictionaryWithObject:@"Value"
                                            forKey:@"Key"];
   error = @"xxx";
   data = [NSPropertyListSerialization dataFromPropertyList:dictionary
                                                     format:NSPropertyListOpenStepFormat
                                           errorDescription:&error];
   NSLog( @"what gives? %@ %@", data, error);
to get what gives? (null) Property list format kCFPropertyListOpenStepFormat not supported for writing.
Curse Apple again! I wrote the plist out in XML format, which for demo purposes was OK, but might bite me later because there are still some Mac OS X Server 1.2 machines there.

Continue reading "Wrapup of that last miserable day at work (Updated)" »

May 4, 2003

Software used

When I looked for a Weblog to install on Mulle, I chose Movable Type, because it looks neat from the start and it does not need to use MySQL. Instead you can configure it to run with Berkeley DB. Now I find that a nice feature, because you don't have to worry about some database daemons running. Berkeley DB is just some files that are written and that can be easily moved around. From my perspective at the moment Movable Type does everything I need.

On the client side I chose Kung Log a nice desktop client, to edit, load and upload your entries. It has a nice option of making automatic links to the tune iTunes is currently playing, which happens to be Bastards of a lying breed from the album "The Crusher" by Amon Amarth. All that HTML from "be" to ".All" was generated by Kung Log! Neat :)

Saw X-Men-2, liked it.

May 5, 2003

ImagePrinter, the program that must die

What is annoying me to no end is that my half-assed coding effort Imageprinter, that was just useful on Mac OS X Server 1.2 (also known as Rhapsody), is still a fairly popular download target here at Mulle, although I clearly wrote on its homepage that it won't do you any good on Mac OS X, people keep downloading it. I could have written a Mac OS X version, but to quote Mrs. Fuchs...
There is a program out now which even in the demo version, can do today what ImagePrinter could do then. The name of the program is OmniGraffle 3.0. With version 3.0 you can now print on the full page. The download version is limited to 20 objects, but you only need one to drag an image into a pre-specified area and to get the same functionality as ImagePrinter. I was considering to release some CD case templates with it, but someone already beat me to it, which is good, because it means less work for me. And less work is "was ich schätze".

So please, please, pretty please with sugar on it, ignore ImagePrinter and use Omnigraffle.

May 6, 2003

Malloc article started

Might as well get something going, so I figured I will start writing the malloc article. Although my iPod has been stolen, with the sources on them, I luckily have a backup copy from last summer. AFAI can remember, I haven't done anything since then so it should be OK.

Started to write a little demo application for the intro chapter. found out that the gcc option -finline-functions seems to have the same or even less effect than a placebo pill. I could get my static inline function to inline when I turned up -O3 from -Os, but specifying or not specifying -finline-functions is a moot anyway with -O3. Curse Stallmann and the FSF and curse Apple. (Though they have little to do with the compiler, there is no guarantee that they didn't muck with it. And if they are innocent, it still hits the right target, he he) No I am too lazy to verify this with Linux (see picture of the previous entry :))

Unfortunately -O3 turned out to be too aggressive and cleverly figured out that my code was a glorified NOP and threw it all away. Took some time to massage the code into being useful enough for the optimizer.

Looked with interest at this PPC 970 article. I don't know how Altivec centered these testings are, as the programs I usually run don't utilize it. So I don't care all that much about AltiVec. But assuming Bryce is not yet AltiVec optimized, that would mean that a single 1.8 Ghz PPC 970 would be on par with a 3 Ghz Pentium IV. Hmm I certainly would hope so... but the relatively low Ghz count on the PPC 970 makes me wonder, if a better architecture can really bridge that big a gap, We will see.

Currently in iTunes Criminals from the album "Viva Emptiness" by Katatonia. I prefer the previous albums at the moment.

Malloc Article first stumbling block

I noticed while trying to reference it from the Malloc article, that I never published the article about threads and locks and how to make them faster. Looking around I know now why, because I never finished it. Problem with the article is that the techniques used are not "Apple" recommended. But I am using them in the MulleMalloc. Looks like I need to write a companion article. Not sure what to do next...

May 7, 2003

No time for the article

Got not time for the article today.
To fill the page here is what's playing now in iTunes: Casa from the album "Urban Terror" by - UN/MO/I Cut -. Oops, oh well a selfmade "remix" of some Urban Terror sample.

May 8, 2003

Gieriges Mac OS X 10.2.6 / Quicktime und kapriziöses Preview.app

Habe eh zu lange gearbeitet um jetzt noch was für den Artikel auf die Kette zu kriegen. Habe mir daher mal gedacht die letzten Stunde Freizeit mit der Installation von Mac OS X 10.2.6 totzuschlagen.

Dann kam das hier:

819 MB erschienen mir zwar etwas übertrieben, aber man hat ja keine Chance zu diskutieren. Aber mal mit Apple-Ctrl-Shift-4 einen Screenshot davon gemacht. Diesen in Preview rein kopiert und versucht mit JPG zu exportieren. Das geht aber nicht, da das Clipboard ein PICT rüberschickt, Preview PICTs aber anscheinend nicht in JPG umwandeln kann (???) merkwürdig. Also erst mal als PNG exportiert, wieder mit Preview geladen und dann als JPG exportiert. Zielgrösse 8K,...16K sinds geworden. Auf mich hört ja keiner...

May 9, 2003

Puzzling Debugtools

Tried to refamiliarize myself with ObjectAlloc and MallocDebug. Chose Clock.app in ObjectAlloc. Let it run a while. Went through the main menu. Then marked it. Now went to the main menu again (especially Apple menu). Woa! Massive leakage. Let it sit for a few minutes, so that some autorelease pools get cleaned up.


Marked it again. Did the same thing, leakage again. Hmm... now try it with MallocDebug. MallocDebug starts up and gives me after the same operations 48 bytes of definite leakage.


48 bytes is nothing. The "possible" leakage is 5.4K and remains stable, no matter what I do in the menu. That would indicate that everything is fine. But on the other hand the idle memory footprint is steadily increasing...

Hmm... need to do more reading.

Wrote some more stuff for the article. Happily found some backup of code, that I thought I would never see again, as it was on my stolen iPod.

May 12, 2003

Continued writing the Article / Omnigraffle ugliness

For some background info I did some research on other mallocs. With every article I read, there's the little scare that it makes my article and all its work obsolete. Fortunately not so yet phew... After writing a good part of the article detailing the workings of the algorithm, I found out a nice way to optimize a certain operation. Which I wanted to implement immediately. Looking at the code though, I saw that what I had programmed before was ALL wrong. How horrible! My code was littered with obvious coding mistakes!?

As it turned out I already had made a much better improvement there and had forgotten all about it. It reduced some code to constant, which today I thought I could optimize from linear to logarithmic. Now I need to redo quite a few drawing again. This also proves that I am getting dumber...

Which leads me to the next bitch and moan, Omnigraffle a feature rich but unfortunately not very accurate drawing program makes my drawing look like this:

  

The minor problem is the strangely skewed box in the lower left corner. I selected all left boxes and said move to front I took all right boxes and said move to background. Then I said "align to grid" nevertheless something's wrong. The geometry inspector doesn't find any difference between the blue 0x50 and the red 0x70 box, apart from the vertical offset, but I sure can see the difference. I can live with that though, although it's a little ugly.

What I can not live with is the way the text hugs the top barrier. Now that is damn ugly.

To say something positive about Omnigraffle, a real nice feature is the possibility to export parts of your drawings as TIFF via copy/paste. That's how the article is done. I draw in OmniGraffle and copy/paste TIFF into TextEdit. In the end I will do a manual conversion into HTML.

May 13, 2003

Connecting an old HP 4 Laserjet to Mac OS X

This is really easy now. You just need a cheap printer server (I bought the DP-101-P+ from D-Link) (cost me €90 shipping inclusive).

The DP-101-P+ offers a choice of Samba, Appletalk and LPR, it can even do DHCP. And you need the really neat HPIJS for Mac OS X packages. After installing HPIJS, and adding a route to the default IP address 128.192.0.10 with sudo route add -net 192.168.0.0 -interface eth0 I got my old Laserjet 4 as a selectable printer model. I chose it and I could print!

Well except that no paper came out!

The DP-101-P+ has a http interface where you can configure things like IP address and the like. You can look at the printer status and some factory settings, but everything seemed to be alright. On mere accident I telnetted into the printer server. This was an accident, because the extremely lacking manual, doesn't tell you that this option exist and I was just trying to telnet to the lpr port really :). To my surprise I was greeted with an ASCII interface and a whole lot more options. I could f.e. look at the printer queue. There were jobs but nothing was printed. Being a software guy I toggled a few options and tried and tried but to no avail.

Another accident brought the solution. When I touched the printer server, the lights on my printer suddenly lit up. As it turns out the ground of the parallel connector did not fit too snugly with the printers socket. I bend the ground inwards a bit, until the connector sat firmly.

Now everything appears to work great.

Did a little bit more research on the article, but really not much for lack of time And for bandwidth waste: playing now Terra Nola from the album "Have A Nice Trip" by Die Apokalyptischen Reiter
Actually I don't use sudo, as that's for wimps. I use root shells :)

Too much work at work to get anything done

But I got a very helpful reply in the mail, for my inquiry about writing a malloc tracer. (Thanks!) So this will be next on my agenda.

May 14, 2003

QuickTime Conspiracy against Window Media Player

To watch the amazing Doom III preview, which is in WMV format, I lacked a suitable viewer on OS X. I upgraded to Quicktime 6.2, but that not-so-surprisingly didn't help. So I had to download Windows Media Player, which so far I wanted to avoid, and tried to install it.

It didn't work.

In the Console I could see that the installer tries to LaunchCFMApp but fails. I looked into the folder but LaunchCFMApp was there. Starting LaunchCFMApp manually gives a bus error. Is my LaunchCFMApp binary corrupt or is it something else, you be the judge:

bash-2.05a$ otool -L /System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp /System/Library/Frameworks/Carbon.framework/Versions/A/Support/LaunchCFMApp: /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 122.0.0) /System/Library/Frameworks/QuickTime.framework/Versions/A/QuickTime (compatibility version 1.0.0, current version 172.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 63.0.0)

Coincidence ??? :) :) :)

In the end I found MPlayer which could play the WMV file. So my recommendation goes to MPlayer.

Windows Media Player running under Mac OS X, what a smart naming scheme ...

May 16, 2003

Procrastination

Didn't get anything done, coz I had no time. Tomorrow doesn't look much better. Saturday or Sunday neither for that matter.

May 18, 2003

First attempt at writing the MallocTracer

My feeble attempt was cut short by my ineptness to handle the linker. I took the easy way out and asked for help on the darwin developers mailing list. That was maybe a good one hour attempt, that lead nowhere. Here's the letter I wrote, in case any of the few thousand readers that frequent this site might know the answer:

I figured to advance with baby steps into this uncharted territory to write a malloc tracer.

So I want to take the libMallocDebug.a replace the debug_malloc.o file with my code and then link it back together into a dylib.

The first baby step was to simply unar the .a archive into its constituent .o files and then naively try to link them back together into a dylib with:

ld -flat_namespace -dylib -o libTestMalloc.dylib _mallocProtocolUser.o _mallocProtocolServer.o excUser.o excServer.o exceptionCatcher.o debug_malloc.o PortListen.o -F/System/Library/PrivateFrameworks -framework vmutils

as the original dylib appears to be linked like that:

bash-2.05a$ !534
otool -L /usr/lib/libMallocDebug.A.dylib
/usr/lib/libMallocDebug.A.dylib:
        /usr/lib/libMallocDebug.A.dylib (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/PrivateFrameworks/vmutils.framework/Versions/A/vmutils (compatibility version 1.0.0, current version 1.0.0)

unfortunately that didn't work, because the linker complains thusly:

ld: _mallocProtocolUser.o illegal undefined reference for multi module MH_DYLIB output file to symbol: dyld_stub_binding_helper from section (__DATA,__la_symbol_ptr) relocation entry: 0

which already sees me at the end of my wits :( Help!

Ciao
	Nat!
Then I tried to synchronize some directories between Windows and Mac OS X. Checked out Unison for that. It appears to work, but unfortunately it can't seem to handle the UTF-8 filenames very well, as it couldn't deal with the Mac OS X file Ügür Mülüsüs Turkisch für Anfänger.pdf at all. Asked for help on this well on the relevant mailing list. I hope that help is on the way...

Another day of failure and missed chances. :)

Hope and Disillusionment

Got a reply off the darwin developers list how to interface with the malloc library events system. This sounded great as it would make writing the tracer a cinch. Basically it's a hook into the malloc system, where you can "sniff" off all malloc related events.

So I just needed to create a dylib with an -init routine that sets the malloc_logger global variable and then start outputting the events to a file. As easy said as done and as I typed the magic incantations:

export DYLD_INSERT_LIBRARIES=/usr/local/libMulleMallocTracer.dylib
export DYLD_FORCE_FLAT_NAMESPACE=1

and then

ls

to generated a trace, I knew, good things were bound to happen.

They were not.

As I searched the /tmp directory in vain for the log file to be generated, I began to understand that the no-show of my debug message on stderr was not just coincidence. I wrote a little test program and linked the library directly. Still nothing happened. Reading through the ld documentation, it became apparent that the -init function is only called, when the shared library is referenced for the first time.

ARGH!

Back to square one. Next up, perusal of the Darwin dyld. I am searchin' for clues.

Playing now: Ghost of the Sun from the album "Viva Emptiness" by Katatonia

May 20, 2003

Branching out into dyld territory

Yesterday I managed to build a dyld from the Darwin Sources. Building something from Darwin used to be a huge pain, one or two years back. Now it's almost effortless. Just a little bit of tweaking required.

I only have an hour tonite, to figure out what to actually do now with the dyld :)

At first I thought that it was merely a linker option to set a different dyld. But not so. So I will just read up on the MachORuntime and then call it a day.

My current theory is, that the dyld path is coming solely from /usr/lib/crt1.o. So I will try to find crt1.o in Darwin somewhere and link that against my dyld and see what happens.

May 22, 2003

Hiatus

Just got the flu. I hope I will recover quickly enough for my holidays next week.

So no more updates the next 10 days or so.

May 23, 2003

Schlegel ist wieder da

About May 2003

This page contains all entries posted to Nat!'s Web Journal in May 2003. They are listed from oldest to newest.

April 2003 is the previous archive.

June 2003 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 4.25