Acts_as_ferret 0.2.1 segfault


#1

Hi,
I just installed via script/plugin from the stable svn tag. (Revision
54)
I’m running Rails 1.1.2 and have Ferret 0.9.3 (with C extensions. no
compilation problems)

I put together a simple model to test it and I’m getting a segfault.
The model:
class Report < ActiveRecord::Base
acts_as_ferret :fields => [:title, :name]
end

$ script/console
Loading development environment.

a = Report.new :title => “test”, :name => “me”
=> #<Report:0xb780db98 @attributes={“name”=>“me”, “title”=>“test”,
“auto_update”=>true, “path”=>nil}, @new_record=true>

a.save
./script/…/config/…/config/…/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:466:
[BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [i386-linux]

vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:466 reads:
self.class.ferret_index << self.to_doc if @ferret_reindex
by inserting logger.debug statements I have been able to determine that
self.to_doc isn’t the problem so I think it must be segfaulting during
the
<<.

Does someone know if I have set up something improperly, or is this
truly a
bug?
Thanks,
John


#2

Hi, John,

my guess is that you have problems with the strings you try to index not
being compliant with the locale of your system. This might be especially
the
case if you retrieve the strings you want to index through ajax.

Please have a look at:

  1. http://www.ruby-forum.com/topic/64430
  2. http://projects.jkraemer.net/acts_as_ferret/wiki/TypoWithFerret (at
    the
    bottom)
  3. http://ferret.davebalmain.com/trac/ticket/55

maybe you could print the strings to the logfile. if they sound a little
strange like query=%C3%A5&commit=search you definitly should try
different
locale settings.

Regards
Jan


#3

sorry, I just realised that you already included the request in your
mail.
with ‘me’ and ‘test’ there should be no locale problems. If these are
the
strings you are actually using my previous mail won’t be of much help…

Have you tried to index something by using ferret without
acts_as_ferret? I
would encourage you to do so by following the short tutorial at
http://ferret.davebalmain.com/api/files/TUTORIAL.html . By doing this
you’ve
eliminated a ‘single point of failure’ and you’ll find out if it is a
problem of your installation of ferret.

Regards
Jan


#4

On 5/23/06, Jan P. removed_email_address@domain.invalid wrote:

sorry, I just realised that you already included the request in your mail. with ‘me’ and ‘test’ there should be no locale problems. If these are the strings you are actually using my previous mail won’t be of much help…

That’s right. I have also tried longer strings with no strange
characters such as “accounts payable” and had the same result.

Have you tried to index something by using ferret without acts_as_ferret? I would encourage you to do so by following the short tutorial at http://ferret.davebalmain.com/api/files/TUTORIAL.html . By doing this you’ve eliminated a ‘single point of failure’ and you’ll find out if it is a problem of your installation of ferret.

I thought I had, but it must have been on my OSX machine. On the
machine in question (Fedora 5) I performed the steps from the
tutorial. Similar result; this time during search instead of insert:
irb(main):002:0> require ‘rubygems’
=> true
irb(main):003:0> require ‘ferret’
=> true
irb(main):004:0> include Ferret
=> Object
irb(main):005:0> index = Index::Index.new
=> #Ferret::Index::Index:0xb7cd6524
irb(main):006:0> index << “this is a new document to be indexed”
=> #Ferret::Index::Index:0xb7cd6524
irb(main):007:0> index << [“and here”, “is another”, “new document”,
“to index”]=> #Ferret::Index::Index:0xb7cd6524
irb(main):008:0> index << {:title => “Programming Ruby”, :content =>
“blah blah blah”}
=> #Ferret::Index::Index:0xb7cd6524
irb(main):009:0> index << {:title => “Programming Java”, :content =>
“yada yada yada”}
=> #Ferret::Index::Index:0xb7cd6524
irb(main):010:0> index.search “document”
(irb):10: [BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [i386-linux]

So my problem lies within ferret. Any ideas what I should try from here?
Thanks for your help
-John


#5

I experience the same problem, although it occurs on line 227, since the
indexes are being created for the first time. Strangely enough, it works
perfectly fine on my OSX Laptop, but it dies on our Fedora Core Linux
server. The following is the error I get.

/var/www/project/config/…/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:227:
[BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [i386-linux]

Aborted

John A. wrote:

On 5/23/06, Jan P. removed_email_address@domain.invalid wrote:

sorry, I just realised that you already included the request in your mail. with ‘me’ and ‘test’ there should be no locale problems. If these are the strings you are actually using my previous mail won’t be of much help…

That’s right. I have also tried longer strings with no strange
characters such as “accounts payable” and had the same result.

Have you tried to index something by using ferret without acts_as_ferret? I would encourage you to do so by following the short tutorial at http://ferret.davebalmain.com/api/files/TUTORIAL.html . By doing this you’ve eliminated a ‘single point of failure’ and you’ll find out if it is a problem of your installation of ferret.

I thought I had, but it must have been on my OSX machine. On the
machine in question (Fedora 5) I performed the steps from the
tutorial. Similar result; this time during search instead of insert:
irb(main):002:0> require ‘rubygems’
=> true
irb(main):003:0> require ‘ferret’
=> true
irb(main):004:0> include Ferret
=> Object
irb(main):005:0> index = Index::Index.new
=> #Ferret::Index::Index:0xb7cd6524
irb(main):006:0> index << “this is a new document to be indexed”
=> #Ferret::Index::Index:0xb7cd6524
irb(main):007:0> index << [“and here”, “is another”, “new document”,
“to index”]=> #Ferret::Index::Index:0xb7cd6524
irb(main):008:0> index << {:title => “Programming Ruby”, :content =>
“blah blah blah”}
=> #Ferret::Index::Index:0xb7cd6524
irb(main):009:0> index << {:title => “Programming Java”, :content =>
“yada yada yada”}
=> #Ferret::Index::Index:0xb7cd6524
irb(main):010:0> index.search “document”
(irb):10: [BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [i386-linux]

So my problem lies within ferret. Any ideas what I should try from here?
Thanks for your help
-John


#6

And the interlinking element seems to be fedora… For both of you there
are
no problems on osx/freebsd. Installations on ubuntu don’t report these
problems and my install on gentoo is fine too. So we need to find out
what’s
the problem with fedora… Are people that are on redhat experiencing the
same problems?

Regards
Jan


#7

Jan P. wrote:

And the interlinking element seems to be fedora… For both of you there
are
no problems on osx/freebsd. Installations on ubuntu don’t report these
problems and my install on gentoo is fine too. So we need to find out
what’s
the problem with fedora… Are people that are on redhat experiencing the
same problems?

Regards
Jan

I just tried rebuilding ferret with -Os instead of -O0 as was in the
makefile that was generated (i’m sorta new to this whole ruby thing so I
don’t know how that gets created). And now it works fine.

So after running
ruby setup.rb config
I went into ext/ modified Makefile, changed -O0 to -Os in the CFLAGS,
and ran make, then went back up a directory and ran
rake setup.rb
and that installed it, and now everything is working just fine.

Jordan


#8

I followed Jordan’s steps and the tests all pass now. Thanks Jordan!
Thanks Jan!


#9

@Jordan: great, thanks for pointing this out!

@John: does this the trick for you too?

Jan


#10

the C extension is littered with these warnings:

warning: cast to pointer from integer of different size

which can be harmless, or not, but ive definitely seen these warnings
gradually disappear from other stuff after running gentoo-amd64 for a
while…

gdb just does this:

Program received signal SIGSEGV, Segmentation fault.
Cannot remove breakpoints because program is no longer writable.
It might be running in another process.
Further execution is probably impossible.
0x00002b670aad0337 in ?? ()

)too lazy to compile ruby with -g to see if its more informative…(

cheers


#11

On 6/3/06, carmen removed_email_address@domain.invalid wrote:

clearly coming from the C code somewhere.
You need to run rake ext to copy the missing headers to the right
place. This won’t help you with your segfault though.


#12

John A. wrote:

I followed Jordan’s steps and the tests all pass now. Thanks Jordan!
Thanks Jan!

i get this error as well, with the trunk of acts_as_ferret, and whatever
ferret was installed via gems (0.9.3 i think). watching that install, it
built the C extensions, and the makefile had the systemwide defaults -O2
-pipe. checked out the trunk of ferret, and it refuses to build the C
extensions due to missing header errors (headers from its own files no
less) but at least thats solves the problem, since the segfault is
clearly coming from the C code somewhere.

obviously that doenst help narrow it down much. thanks for the tips
anyways …


#13

David B. wrote:

On 6/3/06, carmen removed_email_address@domain.invalid wrote:

the C extension is littered with these warnings:

warning: cast to pointer from integer of different size

These will be fixed in a future version. Hopefully the next version.

I also had the same problem. Fixed with -0s

aj


#14

On 6/3/06, carmen removed_email_address@domain.invalid wrote:

the C extension is littered with these warnings:

warning: cast to pointer from integer of different size

These will be fixed in a future version. Hopefully the next version.