How to fix MacPort’s version of w3m from crashing on Mac OS X 10.7 Lion

I like to use w3m command to display HTML content in emails under emacs.

I recently noticed some w3m instability after I upgraded to Mac OS X 10.7 Lion:

$ w3m http://www.nytimes.com/
Segmentation fault: 11

Mac OS X also offered a helpful message of w3m quit unexpectedly and offered up a Problem Report that looked like this:

Process:         w3m [835]
Path:            /opt/local/bin/w3m
Identifier:      w3m
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  bash [3425]

Date/Time:       2012-06-23 22:07:41.760 -0500
OS Version:      Mac OS X 10.7.4 (11E53)
Report Version:  9
Sleep/Wake UUID: 622A3F05-8259-4DF2-82F6-3CACB28E7F3D

Interval Since Last Report:          210793 sec
Crashes Since Last Report:           2
Per-App Crashes Since Last Report:   1
Anonymous UUID:                      FCCF1BD2-936E-4A92-A3C1-D6C071E5132D

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:
--> 
    __TEXT                 0000000109832000-00000001098b7000 [  532K] r-x/rwx SM=COW  /opt/local/bin/w3m

Application Specific Information:
objc[835]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   w3m                           	0x000000010989027b pushValue + 75
1   w3m                           	0x000000010984ad7b flushline + 2523
2   w3m                           	0x000000010984f40b HTMLtagproc1 + 2875
3   w3m                           	0x0000000109852b54 HTMLlineproc0 + 1876
4   w3m                           	0x00000001098564b2 loadHTMLstream + 1954
5   w3m                           	0x00000001098495f6 loadHTMLBuffer + 182
6   w3m                           	0x000000010984444a loadSomething + 26
7   w3m                           	0x0000000109847f48 loadGeneralFile + 6296
8   w3m                           	0x00000001098342e6 main + 4838
9   w3m                           	0x0000000109832ed4 start + 52

The above is pretty annoying, and after many Web Searches I found MacPort Ticket 30710.

Which explains that the current MacPorts version of boehmgc package isn’t Lion compatible.

Fortunately, the solution explained in the MacPorts ticket is simple, instead of the boehmgc package, use the newer boehmgc-devel package instead.

To make the switch I ran the following commands:

$ sudo port deactivate w3m boehmgc
--->  No broken files found.

$ sudo port install boehmgc-devel w3m 
...
--->  No broken files found.

And now w3m works well under Mac OS X 10.7 Lion.