openvenues / ruby_postal

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

Keep getting a Segmentation Fault when I require ruby_postal #3

Closed miwest929 closed 8 years ago

miwest929 commented 8 years ago

I keep running into a Segmentation Fault whenever I require ruby_postal/parser. I have no idea why this is happening. Any assistance to help me diagnose the error would be much appreciated. Ruby version

~/paas-source/ruby/ruby-postal-demo [master] $ ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

ruby_postal gem version

~/paas-source/ruby/ruby-postal-demo [master] $ bundle show ruby_postal
/Users/mwest/.rvm/gems/ruby-2.1.2/gems/ruby_postal-0.3.0

Machine information

~/paas-source/ruby/ruby-postal-demo [master] $ uname -a
Darwin C02M3DQDFD57 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64

Contents of demo.rb

require 'ruby_postal/parser'

When I run that script with ruby demo.rb I receive the following:

/Users/mwest/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0/ruby_postal-0.3.0/ruby_postal/cpostal/parser.bundle: [BUG] Segmentation fault at 0x007fb736000000
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:
     * ~/Library/Logs/CrashReporter
     * /Library/Logs/CrashReporter
     * ~/Library/Logs/DiagnosticReports
     * /Library/Logs/DiagnosticReports
   for more details.

-- Control frame information -----------------------------------------------
c:0009 p:-17553102548318 s:0039 e:000038 TOP    [FINISH]
c:0008 p:---- s:0037 e:000036 CFUNC  :require
c:0007 p:0115 s:0033 e:000032 METHOD /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0006 p:0007 s:0023 e:000022 TOP    /Users/mwest/.rvm/gems/ruby-2.1.2/gems/ruby_postal-0.3.0/lib/ruby_postal/parser.rb:1 [FINISH]
c:0005 p:---- s:0021 e:000020 CFUNC  :require
c:0004 p:0073 s:0017 e:000016 BLOCK  /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135
c:0003 p:0444 s:0014 e:000013 METHOD /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144
c:0002 p:0007 s:0004 E:0008e8 EVAL   demo.rb:3 [FINISH]
c:0001 p:0000 s:0002 E:001828 TOP    [FINISH]

demo.rb:3:in `<main>'
/Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
/Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
/Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
/Users/mwest/.rvm/gems/ruby-2.1.2/gems/ruby_postal-0.3.0/lib/ruby_postal/parser.rb:1:in `<top (required)>'
/Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'

-- C level backtrace information -------------------------------------------
0   libruby.2.1.0.dylib                 0x000000010870f87b rb_vm_bugreport + 251
1   libruby.2.1.0.dylib                 0x0000000108594dc5 report_bug + 357
2   libruby.2.1.0.dylib                 0x00000001085950ef rb_bug + 207
3   libruby.2.1.0.dylib                 0x000000010868256f sigsegv + 207
4   libsystem_platform.dylib            0x00007fff86b375aa _sigtramp + 26
5   libpostal.0.dylib                   0x0000000108a1c797 cstring_array_from_char_array + 231
6   ???                                 0x00007fff576b6d80 0x0 + 140734660046208

-- Other runtime information -----------------------------------------------

* Loaded script: demo.rb

* Loaded features:

    0 enumerator.so
    1 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/enc/encdb.bundle
    2 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/enc/trans/transdb.bundle
    3 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/rbconfig.rb
    4 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/compatibility.rb
    5 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/defaults.rb
    6 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/deprecate.rb
    7 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/errors.rb
    8 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/version.rb
    9 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/requirement.rb
   10 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/platform.rb
   11 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/basic_specification.rb
   12 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/stub_specification.rb
   13 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/util/stringio.rb
   14 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/specification.rb
   15 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/exceptions.rb
   16 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
   17 thread.rb
   18 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/x86_64-darwin13.0/thread.bundle
   19 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb
   20 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb
   21 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems.rb
   22 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/path_support.rb
   23 /Users/mwest/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Abort trap: 6

Any ideas about the root cause or suggestions on how to get to diagnose it?

albarrentine commented 8 years ago

Hey Mike - thanks for the detailed report, and sorry that's been happening to you.

There are two things I would check:

  1. Did everything download correctly? If you run du -h on the data dir (if, when compiling libpostal, you passed ./configure --datadir=/data the datadir would be /data/libpostal), it should take up about 2.2G of space
  2. Does the machine/VM have enough memory? All said and done libpostal should need about 1.5G RAM

Given the function it's crashing on, which is toward the middle of loading the parser, I suspect that one of those conditions might be the cause. If not, let me know.

miwest929 commented 8 years ago

Thanks @thatdatabaseguy for your detailed analysis. I'm still in the process of testing each of your hypotheses. I'll let you know what I discover!

miwest929 commented 8 years ago

@thatdatabaseguy I was able to get ruby_postal working without a Segmentation Fault. The issue was 1.. The data download phase must have previously failed despite taking up 2.1G. I simply reinstalled libpostal from scratch and redownloaded the data. Now my demo.rb works as expected. Thank you for your assistance. I'm closing this issue.