Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Marc Juul
RE: Segmentation Fault [ reply ]  
2011-10-15 04:02
I tried switching to Oracle JDK 1.7.0 and uninstalling and reinstalling rjb.

I tried uninstalling rjb and installing the 1.3.0 version.

Still getting the segfault.

By: Marc Juul
RE: Segmentation Fault [ reply ]  
2011-10-15 03:48
I'm having the same issue but on Ubuntu 11.04, rails 3.1 and with a 32 bit processor instead.

If I run Rjb::load in the same method where I'm using it, the problem goes away, but if I load only once during Rails startup I get a segmentation fault when I try to do anything that requires more than the most trivial of resources afterwards. Oddly it doesn't segfault on Rjb::load.

By: arton Tajima
RE: Segmentation Fault [ reply ]  
2011-04-08 15:01
Hi Nunya

Thanks your follow up.
I have no clue now, in your case, only the difference is REE's patch level. And the difference between Rails/DelayedJob and sciript/console is process forking.
So (but I don't believe that) the resolution is JVM 1.6 is not process forking friendly. Ummm but I don't think so.
BTW, I'm happy that you succeeded.

Cheers.

By: Nunya Gupta
RE: Segmentation Fault [ reply ]  
2011-04-08 14:46
Hi!

Thank you for all your effort.

It really is perplexing. As far as I know, I have two identical servers--down to the bit. I installed everything myself and am the only user. Yet the one will only work with 1.5 (after some minor surgery--see my other message).

Just to make sure it wasn't anything with my .jar file, I ran a test with itext.jar (http://itextpdf.com/), and it also produced a segmentation fault.

Oddly, if I commented out the offending initializer that loaded the .jar (called classifier.rb), ran script/console, then followed the same process that classifier.rb performs (i.e., require 'rjb', Rjb::load, etc.), it ran successfully. So...what the heck? Maybe something in the way Rails boots (but _only_ on this machine!) was causing the issue? Trying to run classifier.rb from a pre_initializer didn't work. Another oddity: running the same code from within a model (i.e., not loading it in an initializer) produced a seg fault.

Running the classifier.rb processes from irb worked fine.

At any rate, I'm guessing my case is very rare/edge, and downgrading to Java 1.5 solved the issue. Hopefully my spelunking helps a bit.

By: Nunya Gupta
RE: Segmentation Fault [ reply ]  
2011-04-08 14:30
Well, after 3 days of no luck, I uninstalled all Java JDK's, cleaned out the cruft left behind in the /usr/lib/jvm directory, uninstalled rjb, reinstalled Sun's Java 1.5 JDK (on ubuntu the package is sun-java5-jdk), reset my JAVA_HOME, added it to my PATH, and for good measure added the LD_LIBRARY_PATH, then reinstalled rjb....and it works now. Happy day.

Hopefully this will help others facing the segfault issue--just go with 1.5. It really is odd though, as rjb works fine on an identical machine running Sun Java 6 JDK.

By: arton Tajima
RE: Segmentation Fault [ reply ]  
2011-04-08 13:45
Hi,

I've installed REE (334) on my Linux box. Because I'd like to reproduce the problem.
So, please let me get the most least reproduce case(script fragment). I hope it must be DelayedJob with J2SE object.
It's ridiculous that I suppose the segv was caused by threading issue. But you could successfully run jobs on REE 253. So I can't figure out the cause of the segv.

Thanks.

By: Nunya Gupta
RE: Segmentation Fault [ reply ]  
2011-04-07 20:14
Forgot to answer some questions:

- Yes, myclassfier.jar is in the current directory (rails root).

- Sorry, I made a typo: yes, right side is MYClassifier.getClassfier("file.gz"). This file is also in the current directory (rails root).


By: Nunya Gupta
RE: Segmentation Fault [ reply ]  
2011-04-07 18:13
ruby -v is:
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03

Interestingly, on the machine that works, ruby -v is:
ruby 1.8.7 (2010-04-19 patchlevel 253) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2010.02

Not sure if that matters.

Here is the script/console output:

>> require 'rjb'
=> true
>> p Rjb::load('myclassifier.jar', ['-Xmx400m'])
nil
=> nil
>> $stdout.flush
=> #<IO:0x1cfb9e8>
>> MYClassifier = Rjb::import('name.of.CRFClassifier')
=> #<Rjb::Edu_stanford_nlp_ie_crf_CRFClassifier:0x7713cc8>
>> p MYClassifier
#<Rjb::Com_our_CRFClassifier:0x7713cc8>
=> nil
>> $stdout.flush
=> #<IO:0x1cfb9e8>
>> CLASSIFIER = CRFClassifier.getClassifier("file.gz")
Loading classifier from /var/www/our.app.directory/releases/20110407175841/file.ser.gz ... done [0.5 sec].
=> #<Rjb::Rjb_JavaProxy:0x76bee80>


I _CAN_ successfully load and execute my code from script/console, _IF_ I don't try to preload it in an initializer. However, running it in Rails (Phusion Passenger), or running it from DelayedJob (where it is needed), results in the SegFault.

Again, thank you.


By: arton Tajima
RE: Segmentation Fault [ reply ]  
2011-04-07 17:54
Hi Nunya

It seems jvm is 64bit app, is Ruby also 64bit ?
Please copy&paste the output of 'ruby -v' and please let me see the console output of the script using copy and paste.

require 'rjb'
p Rjb::load('myclassifier.jar', ['-Xmx400m']) # does myclassfier.jar sit on the current directory ?
$stdout.flush
MYClassifier = Rjb::import('name.of.CRFClassifier')
p MYClassifier
$stdout.flush
CLASSIFIER = CRFClassifier.getClassifier("file.gz") # is the right side 'MYClassifier.getClassfier("file.gz") ?
p CRFClassifier
$stdout.flush


By: Nunya Gupta
RE: Segmentation Fault [ reply ]  
2011-04-07 16:57
Hi!
It seems to occur after the Rjb::load.

I am running rjb from an initializer in Rails 2.3.10. I'm using it to set a constant CLASSIFIER text processing jar (this gets accessed throughout the rails application to process text).

commands are:
require 'rjb'
Rjb::load('myclassifier.jar', ['-Xmx400m'])
MYClassifier = Rjb::import('name.of.CRFClassifier')
CLASSIFIER = CRFClassifier.getClassifier("file.gz")

JAVA_HOME is /usr/lib/jvm/java-6-sun/

ruby -rubygems -rrjb -e 'p Rjb::VERSION' returns "1.3.4"

ls -l /etc/alternatives/javac
/etc/alternatives/javac -> /usr/lib/jvm/java-6-sun/bin/javac

java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

Thanks!

By: arton Tajima
RE: Segmentation Fault [ reply ]  
2011-04-07 16:22
Sorry, the correct command line is
ruby -rubygems -rrjb -e 'p Rjb::VERSION'

By: arton Tajima
RE: Segmentation Fault [ reply ]  
2011-04-07 15:56
When dit you get segmentation falut ? At Rjb::load or Rjb::import ?
Please let me know more details especially rjb version.
Does 'ruby -rubygems -rjb 'p Rjb::VERSION' run ?

By: Nunya Gupta
Segmentation Fault [ reply ]  
2011-04-07 15:22
I get a Segmentation Fault regardless of JDK / JAVA_HOME variable.

I've tried installing the gem against sun-java6-jdk, sun-java5-jdk and openjdk-6-jdk with no luck. Every time I try to run some Java code, I get a Segmentation Fault.

Environment is Ubuntu 10.0.4LTS, Ruby EE 1.8.7

Oddly, I have 2 identical machines: rjb works on one, but not the other.

Any tips/pointers would be much appreciated. I'm not a Java guy--just ruby--so I don't know how to debug this. I've already read everything online about rjb and segmentation fault, but no luck so far.
Thanks