GPG insecure memory

Just a quick note to record the answer to a question that’s been bugging me for quite a while:

% gpg --list-keys 64EBE220  
gpg: WARNING: using insecure memory!
gpg: please see http://www.gnupg.org/faq.html for more information
pub   1024D/64EBE220 2006-11-11 [expires: 2009-11-10]
uid                  Dag-Erling Smørgrav 
uid                  Dag-Erling Smørgrav 
uid                  [jpeg image of size 3315]

The textbook solution is to chmod u+s =gpg, but this doesn’t always work on FreeBSD (especially on amd64). The reason is that the default limit on wired pages (which includes the unified buffer cache) is too low. It is initialized at boot time to approximately one-third of system memory. Increasing it to, say, half your system memory should fix the GnuPG issue:

% sudo sysctl vm.max_wired=524288
vm.max_wired: 333091 -> 524288

Remember that vm.max_wired is in pages, not in bytes. On i386 and amd64, a page is 4096 bytes, so the above allows for up to 2 GB of wired memory.

No, really

In support of my earlier claim that Java enums are subclassable, here is an example inspired by McGraw-Hill’s SCJP 6 study guide:

public enum CoffeeSize {
    REGULAR(4), BIG(8), HUGE(12), OVERWHELMING(16) {
        public void drink() { super.drink(); System.out.println("barf"); } };
    private int oz;
    CoffeeSize(int oz) { this.oz = oz; }
    public void drink() { for (int n = 0; n < oz; ++n) System.out.println("glug"); }
    public static void main(String[] args) { CoffeeSize.OVERWHELMING.drink(); }
}

No, silly! It’s an enum!

Ah, to have been a fly on the wall when they designed Java 5. Imagine a meeting between three unnamed Java language designers:

JLD#1: OK, so, new language features for 5, what’s next on our list? Anyone?
JLD#2: There’s always enums.
JLD#3: Not enums again!
JLD#2: Well, they keep asking for it. It’s getting pretty tiresome. Why don’t we just give them enums, and be done with it? How hard can it be?
JLD#1: OK, let’s consider enums for a minute. How do we do that? Continue reading “No, silly! It’s an enum!”

2,600 years of progress

I just finished The Dreaming Void, the first book in Peter F. Hamilton‘s Void Trilogy. Overall an excellent book, but I do have a nit to pick… a rather big one, in fact.

To provide some background: the Void Trilogy is set in the same continuity as Misspent Youth and the Commonwealth Saga, about 2,500 years after the former, 1,200 years after the latter, and close to 2,600 years after our time. Continue reading “2,600 years of progress”