ruby - Playing with Scrapi in Rails 3.. getting Segmentation Fault error / Abort Trap -
what i've done far..
sudo gem install scrapi sudo gem install tidy
this didn't work because didn't have libtidy.dylib
so did :
sudo port install tidy sudo cp libtidy.dylib /library/ruby/gems/1.8/gems/scrapi-1.2.0/lib/tidy/libtidy.dylib
then started following simple railscast @ : http://media.railscasts.com/videos/173_screen_scraping_with_scrapi.mov
right after mr. bates finished first save scrapitest.rb
, tried run code :
require 'rubygems' require 'scrapi' scraper = scraper.define process "title", :page_name => :text result :page_name end uri = uri.parse("http://www.walmart.com/search/search-ng.do?search_query=lost+season+3&ic=48_0&search_constraint=0") p scraper.scrape(uri)
with code :
ruby scrapitest.rb
and returned error :
/library/ruby/gems/1.8/gems/tidy-1.1.2/lib/tidy/tidybuf.rb:39: [bug] segmentation fault ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] abort trap
completely out of ideas..
i had issue , follow-up issue seg fault happen non-deterministically.
i followed steps here - http://rubyforge.org/tracker/index.php?func=detail&aid=10007&group_id=435&atid=1744
in tidy-1.1.2/lib/tidy/tidylib.rb:
1. add line 'load' method in tidylib: extern "void tidybufinit(void*)"
2. define new method called 'buf_init' in tidylib: # tidybufinit, using default allocator # def buf_init(buf) tidybufinit(buf) end
then, in tidy-1.1.2/lib/tidy/tidybuf.rb:
3. add line initialize method of tidybuf below malloc: tidylib.buf_init(@struct)
so looks this:
# tidybufinit, using default allocator # def buf_init(buf) @struct = tidybuffer.malloc tidylib.buf_init(@struct) end
4. completeness, make brennan's change adding allocator field tidybuffer struct looks this: tidybuffer = struct [ "tidyallocator* allocator", "byte* bp", "uint size", "uint allocated", "uint next" ]
Comments
Post a Comment