Author Archive

February 13th 2010

Catchlogger

Post seriousness: 70%.

Catchlogger [jar] [git src] checks that exceptions are being logged properly.

It’s entirely fallible, but, if your codebase is prone to catching and ignoring exception, and you use log4j, it’s Very Helpful.

For example:


try {
foo();
} catch (IOException e) {
logger.error("bar: failed to foo", e);
}

This is fine; an error has occurred and it’s full stacktrace will be placed in the log4j configured log.


try {
foo();
} catch (IOException e) {
logger.error(e);
logger.info("oh noes", e);
e.printStackTrace();
}

None of these, however, will do anything useful. The first logs just the toString() to the error log, info is too low-level to log exceptions at, and printStackTrace() doesn’t necessarily go anywhere at all.

For this block, catchlogger will issue:
IOException e unused at (Test.java:15) in public main(String[] args) in path.

The JAR is huge as it pulls in the entire Eclipse compiler to parse the source. BSD/MIT licensed.

No Comments yet »

April 13th 2009

The Free Software Definition

The GNU project publishes a list of four Freedoms and recommend a single license*, the GPL.

They claim the word “Free” for software available under the GPL.

Let us consider some developer freedoms, and some alternative licenses for blocks of code:

Link / Use Four boring freedoms Reuse the code Sue author
Proprietary
GPL
Freeware**
LGPL
BSD/MIT/ISC/etc.
PD/WTFPL***/etc.

Looking at this, it’s reasonably obvious to me which licenses offer the most Freedom to the developer; that being the BSD/MIT/ISC family.

These are the licenses I use personally, and the licenses I use to define Free Software; I don’t see how it can be taken any other way.

Continue Reading »

3 Comments »

April 13th 2009

Finalizers considered harmful

I diagnosed an interesting problem at work recently; our application, when running on some enterprise platforms was eventually (over a number of days) running out of memory, grinding to a halt then fatally OutOfMemoryErroring, regardless of how much heap it was given.

Eclipse Memory Analysis Tool (via. DTFJ for the IBM heapdumps) is rather resource hungry, needing massively increased the heap (~7gb, i.e. can’t be run on an 32-bit machine) and stack size (~8mb). However, once the heap dump had been loaded (1h+), it was reasonably obvious (after #266231) what was happening:

The finalizers wern’t being processed fast enough.

The finalization thread is run at a lower priority, and, seemingly, on the configurations on these machines/OS/JVM combinations, it was getting no time at all.

For historical reasons, quite a few large classes in our codebase have:

void finalize() {}

..in, that is, finalizers that do nothing at all. These empty finalizers still have to be run before the object can be collected, however, so they simply wern’t, quickly leaking memory. The more that was leaked, the slower the JVM was running, so the less time the finalization thread had, a vicious cycle.

I couldn’t find many other people experiencing this on the internet, I can only assume that people simply don’t use finalizers, which can only be a good thing.

One guy had a rather more interesting solution:

public static void main(String[] args)
{
  new Object()
  {
    @Override protected void finalize() throws Throwable
    {
      super.finalize();
      Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    }
  };
  // ...
}

The worst thing is, I can’t really see any disadvantages to this…

No Comments yet »

April 13th 2009

Google Earth “offline installer”

Google seem to be of the incorrect opion that you want your machine infected with Google Update.

The Google Earth download is actually just a cunningly disguised Google Update installer, and it seems to think it needs elevation.

It extracts %TEMP%\GUXXXXX.tmp\GoogleUpdate.exe, then tries to run:

GoogleUpdate.exe /install "appguid={74AF07D8-FB8F-4d51-8AC7-927721D56EBB}&appname=Google%20Earth&needsadmin=true" /installelevated

Instead of this,

GoogleUpdate.exe /install "appguid={74AF07D8-FB8F-4d51-8AC7-927721D56EBB}&appname=Google%20Earth"

..will happily download and extract Google Earth to %TEMP%\7ZipSfx.XXX. This is the unpacked offline installer, but the installer itself still attempts to elevate. Luckily, it’s already unpacked, in:

%TEMP%\7ZipSfx.XXX\program files\Google\Google Earth

Just copy this folder to somewhere convenient and run googleearth.exe.

For reference for other apps, the quoted argument to GoogleUpdate.exe is the last “line” in the downloaded GoogleEarthSetup.exe.

1 Comment »

December 22nd 2008

Noelevate

In Windows Vista, Microsoft added manifests, a way for developers to require that their applications run as administrator, or not at all. This takes control away from the user, me, who I trust, and gives it to some developer (who I might not). While it’s possible to edit the file to remove these manifests, this is hard to do safely and automatically.

I thought it’d be fun to directly fix the problem.

It seems that, like some other things, as far as I can see, there’s no support for this.

Luckily, it’s an even smaller patch than last time. I won’t show it, it’s simply erasure of a jmp. It’s a terrible solution to the problem, and the binary only contains fixes for kernel32.dll as seen on x64 SP1 and x32 SP1 as of now, it could break at any point. I implore nobody to use this utility seriously.

noelev (asc) (cpp) (pdb) works much like the reverse of the unix “sudo” command, running a command via. it makes it run without elevation.

It’s not infectious, so it won’t work for all applications (like some setup applications that unpack other installers), and, of course, some applications actually don’t work without elevation.

A lot of Windows components actually appear to cope relatively gracefully with the unexpected lack of permissions, unlike, say, the nVidia components. I was hoping to find an entertaining failure to screenshot, but they’re all boring. :(

2 Comments »

December 14th 2008

Ergonomics

I decided on Thursday that I don’t actually use my right-thumb for any keys whilst typing, my left exclusively operates the space-bar, and there are no useful modifier keys on the right-hand side of a Microsoft Ergonomic 4000 Keyboard.

I decided to add something useful:
MS Ergonomic Keyboard 4000 with nipple

If you can’t tell by the head, it’s the remains of an xbox 360 controller:
..and what it looks like underneath

This, combined with a modified version of mousex gives you an almost usable mouse.

Now I just need to train myself to use it.

As an aside, I used to be worried about damaging the wrist wrests and the other pieces of the body (both of which you can see mutilated above). I am no longer, they’re almost indestructable. I had to switch from a craft knife to a stanley knife to get through the faux-leather on the wrist wrest.

3 Comments »

Next »