Apple Mail crash: “bad external relocation length”

,

(I’m writing this so that other people who encounter this problem can search for this post and find at least a bit of advice.)

One day not so long ago, Apple Mail started crashing on launch on my PowerPC G4 Powerbook. The crash report said:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000008fe0105c
Crashed Thread:  0

Dyld Error Message:
bad external relocation length

I tried a couple of naïve remedies (rebooting, restoring Mail.app from the most recent Time Machine backup) without any success.

I tried starting Mail under a new user account; it crashed there too. Also, iChat crashed on launch with exactly the same error. These two pieces of evidence led me to think that the problem was nothing to do with my e-mail: perhaps a corrupted dynamic library.

In gdb, the backtrace at the point of the crash looked like this:

(gdb) run
Starting program: /Applications/Mail.app/Contents/MacOS/Mail
Reading symbols for shared libraries +++++++++++..................... done
dyld: bad external relocation length

Program received signal SIGTRAP, Trace/breakpoint trap.
0x8fe0105c in __dyld_dyld_fatal_error ()
(gdb) bt
#0  0x8fe0105c in __dyld_dyld_fatal_error ()
#1  0x8fe080e8 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#2  0x8fe01774 in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#3  0x8fe01048 in __dyld__dyld_start ()

Running lsof on the stopped process showed that the process had open a bunch of files in /System/Library and nothing else. So I restored /System from backup. Still no luck.

I reported this to bugreport.apple.com (bug 6338133) and Apple replied:

After further investigation it has been determined that this is a known issue, which is currently being investigated by engineering. This issue has been filed in our bug database under the original Bug ID# 6161821.

Which would nice if I could look at bug 6161821, but as far as I can tell, Apple only let you look at your own bugs.

So I left the problem for a few weeks. Then I upgraded to 10.5.6 (using the combo updater since the System Update was known to have problems) and tried Mail again. This time it booted, and started converting the format of 109,000 messages. Half an hour later it crashed with the same “bad external relocation length” as before. But before it crashed, the converter was stuck for several minutes converting my “Junk” folder. So I moved this folder (actually, the whole of my user account ~/Library/Mail/POP-gdr@localhost) to /tmp and tried again. After another half an hour of converting, Mail ran successfully.

So maybe it was an invalid mail message that provoked the bug? But if so, why did iChat also crash, and why did Mail not run on a fresh account? (I still have the offending “Junk” folder, all 7135 messages of it, if some knowledgeable person can tell me what to look for.) If that is the case, it’s a bit worrying that the entire world can make my mail application crash just by sending me some junk mail.