justsoftwareconsulting.com

July 27, 2009

Figured a workaround for the Hpricot bug ‘BUS ERROR’

Filed under: Ruby On Rails — rob @ 8:01 pm

As detailed here: , a bunch of people have problems with Hpricot core dumping with this sig:

/Library/Ruby/Gems/1.8/gems/hpricot-0.8.1/lib/hpricot/parse.rb:33: [BUG] Bus Error ruby 1.8.6 (2007-09-24) [universal-darwin9.0]

The problem is exactly that the fetched page is 16384 bytes long, and so one workaround is the following:

f = open(url)
f.write("  ") if f.size == 16384
doc = Hpricot(f)

Whee. Cheezits are us, but it works.

The other thing that works is to increase the buffer size to a point where Hpricot doesn’t care:

Hpricot.buffer_size = 262144 

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress