Closed hkf closed 11 years ago
Can you post the code that produces the bug? I am not able to reproduce.
Thanks for the prompt response!
The problem started in the context of a rails application, however in trying to figure it out I filled in your example code and tried that. It fails as described above. The code is here https://gist.github.com/4568541.
In the same directory as this file is a Gemfile that includes only your gem and a sub-directory containing 'full' jars set. I run the script directly using
ruby ./example.rb
Any leads that I may follow as well are welcome. I will get another copy of the jars and see about that. Here is a longer version of the stack trace, surely more informative to you than to me.
Invalid memory access of location 0x0 rip=0x10ca1a4ed
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:45: [BUG] Segmentation fault
ruby 1.9.3p374 (2013-01-15) [x86_64-darwin12.2.1]
-- Control frame information -----------------------------------------------
c:0015 p:---- s:0058 b:0058 l:000057 d:000057 CFUNC :load
c:0014 p:0028 s:0053 b:0053 l:000052 d:000052 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:45
c:0013 p:0029 s:0050 b:0050 l:000049 d:000049 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:38
c:0012 p:0117 s:0045 b:0045 l:000044 d:000044 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:27
c:0011 p:0026 s:0040 b:0040 l:000039 d:000039 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:63
c:0010 p:0056 s:0035 b:0035 l:000024 d:000034 BLOCK /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:71
c:0009 p:---- s:0030 b:0030 l:000029 d:000029 FINISH
c:0008 p:---- s:0028 b:0028 l:000027 d:000027 CFUNC :each
c:0007 p:0017 s:0025 b:0025 l:000024 d:000024 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:68
c:0006 p:0072 s:0022 b:0022 l:000021 d:000021 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:55
c:0005 p:0061 s:0019 b:0019 l:000018 d:000018 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/stanford-core-nlp-0.5.1/lib/stanford-core-nlp.rb:125
c:0004 p:0020 s:0016 b:0016 l:000015 d:000015 METHOD /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/stanford-core-nlp-0.5.1/lib/stanford-core-nlp.rb:140
c:0003 p:0176 s:0009 b:0009 l:000188 d:001ef0 EVAL ./example.rb:33
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:000188 d:000188 TOP
-- Ruby level backtrace information ----------------------------------------
./example.rb:33:in `<main>'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/stanford-core-nlp-0.5.1/lib/stanford-core-nlp.rb:140:in `load'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/stanford-core-nlp-0.5.1/lib/stanford-core-nlp.rb:125:in `bind'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:55:in `bind'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:68:in `load_default_jars'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:68:in `each'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:71:in `block in load_default_jars'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/binding.rb:63:in `load_jar'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:27:in `load'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:38:in `load_jar_rjb'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:45:in `init_rjb'
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:45:in `load'
Do you have sufficient memory to create the models? According to Stanford NLP's page you would need at least 2GB of memory to create the models. I was facing the segmentation fault problem too when I ran the sample code on an older system with limited memory. Could insufficient memory be whats causing your problem too?
Yes, I have plenty of memory. How do you suggest enforcing or suggesting the 2GB allowance? I tried setting
StanfordCoreNLP.jvm_args = ['-Xms1024M', '-Xmx2048M']
as a way of allowing for more memory, but it failed the same, just as fast.
Just got the same issue. Worked fine in the past.. Here is the trace (well beginning):
Invalid memory access of location 0x0 rip=0x10ba574ed /Users/user.rvm/gems/ruby-1.9.3-p125/gems/bind-it-0.2.6/lib/bind-it/jar_loader.rb:45: [BUG] Segmentation fault ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
-- Control frame information ----------------------------------------------- ...
@stpn @hkf Can you both tell me if you are using Rjb 1.4.3, and if not, whether using that version fixes the problem?
gem uninstall rjb
gem install rjb -v 1.4.3
I suspect this is the same issue: https://github.com/louismullie/treat/issues/41
Perhaps related, the trace looks remarkably similar.
After making sure to use 1.4.3, by doing as above, I get no segfault. But I get a new Java problem
ruby ./example.rb
/Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/stanford-core-nlp-0.5.1/lib/stanford-core-nlp.rb:188:in `method_missing': java.io.FileNotFoundException (RuntimeException)
from /Users/harold.figueroa/.rvm/gems/ruby-1.9.3-head/gems/stanford-core-nlp-0.5.1/lib/stanford-core-nlp.rb:188:in `load'
from ./example.rb:35:in `<main>'
Ideas?
Perhaps some gemspec should be specific about rjb for now, if not a solution it would allow bundle to get the more stable choice.
@louismullie This fixed my issue as well, thanks!
:+1:
Thank you @louismullie !
OK. Working. Thank you!
For completeness:
My best guess on my 'remaining' problem was that the example code in the attached gist sets an English model then goes ahead and says use French ... Oops. Crash. Maybe this should be avoided.
I uninstall the gem and rjb, then when I bundle the latest rjb still comes down. I don't know whether the recent update should be reflected in gem yet.
The trace is really horrible, but it begins with the simple:
I have used your library successfully in the past, in fact I know precisely when, because I forked it to fix some config paths https://github.com/hkf/stanford-core-nlp/commit/22afbf1f7514882b66e6e9a51b01ef8549e5add2
I am using RVM and this segfault is not exclusive to the Ruby version. It has also failed with 1.9.2 and JRuby 1.7.0 and 1.7.2. I have even installed RVM from scratch after imploding.