openvenues / ruby_postal

Ruby bindings to libpostal for fast international address parsing/normalization
MIT License
141 stars 12 forks source link

Getting Segmentation Fault when trying to run require 'ruby_postal/expand' #11

Open detournemint opened 6 years ago

detournemint commented 6 years ago

Hi there, I've installed libpostal via the instructions, i created a /data folder with full permissions open. i have the ruby_postal gem installed and when trying to run in rails console

2.1.4 :001 > require 'ruby_postal/expand'
/home/greggh/.rvm/gems/ruby-2.1.4/gems/ruby_postal-1.0.0/lib/ruby_postal/cpostal/expand.so: [BUG] Segmentation fault at 0x00000000000004
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]

My data dir is 1.9 gb which is the only other cause i saw of a segfault error when I looked it up. (Issue #3 ) but no dice. I have 30gb of ram and 500 gb of disk space.

Any idea what's up or what I can try? It seems to be rails specific as running a file with just the import statement ruby test.rb works just fine

albarrentine commented 6 years ago

Hey @greggawatt, which OS is this, and which version of libpostal? And is it running in a VM or container?

I just tested it out again with the latest version of libpostal on Mac with Ruby 2.2.4 and everything seemed to be working ok. 2.1 is covered by our build, although that's Ubuntu.

detournemint commented 6 years ago

This is a vm running debian and i grabbed the latest version of libpostal today from github. Do you have a rails project you can try it on or try rails runner test.rb with the following in test.rb:

require 'ruby_postal/expand'
puts Postal::Expand.expand_address('Quatre-vingt-douze Ave des Ave des Champs-Élysées')

so for the record ruby test.rb works rails runner test.rb blows up Rails 4.2

albarrentine commented 6 years ago

No, sorry. I'm really not a Ruby/Rails person, and, being a data scientist, most of my work is in Python/NumPy or C (my only real knowledge of Ruby is how the language operates at the C level). If the basic script is working, it seems that either we're doing something in the C extension that's not kosher with Rails, or there may be a bug somewhere else. Afraid I don't have the time right now to look into it in much depth, but I would try searching for the general error of loading C extensions in that version of Rails and see if that turns up anything. If you find that there's a fault with this library, feel free to update here or send a PR.