Rusty Conover
2007-Dec-17 06:57 UTC
[Xapian-devel] Crashes with spelling enabled and perl.
Hi Guys, Here's a simple test case that causes a segfault with the perl bindings patched to enable spelling correction: use strict; use warnings; use Search::Xapian; my $db = Search::Xapian::WritableDatabase->new("test.db", Search::Xapian::DB_CREATE_OR_OPEN); if (!defined($db)) { die("Failed to open xapian_database: $!"); } my $indexer = Search::Xapian::TermGenerator->new(); $indexer->set_flags(Search::Xapian::FLAG_SPELLING); my $document = Search::Xapian::Document->new(); $indexer->set_document($document); $indexer->index_text(lc('test'), 1); $db->add_document($document); undef $db; Here's the patch to enable spelling against Search-Xapian-1.0.4.0: http://rusty.devel.infogears.com/xap-perl-spelling.diff Here's the backtrace against 1.0.4: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1208211776 (LWP 27230)] 0x001c9bbc in Xapian::WritableDatabase::add_spelling (this=0x9d77de0, word=@0xbf846fa0, freqinc=1) at ./include/xapian/base.h:154 154 return dest; Current language: auto; currently c++ (gdb) bt #0 0x001c9bbc in Xapian::WritableDatabase::add_spelling (this=0x9d77de0, word=@0xbf846fa0, freqinc=1) at ./include/xapian/ base.h:154 #1 0x0032608a in Xapian::TermGenerator::Internal::index_text (this=0x9d77dc8, itor={p = 0x0, end = 0x9cb5db8 "", seqlen = 0}, weight=1, prefix=@0xbf84703c, with_positions=true) at queryparser/ termgenerator_internal.cc:207 #2 0x0032506c in Xapian::TermGenerator::index_text (this=0x9c94cd0, itor=@0xbf84702c, weight=1, prefix=@0xbf84703c) at queryparser/ termgenerator.cc:90 #3 0x0017100e in XS_Search__Xapian__TermGenerator_index_text (my_perl=0x9c78008, cv=0x9d7f7e8) at /usr/local/include/xapian/ termgenerator.h:115 #4 0x00c3142d in Perl_pp_entersub () from /usr/lib/perl5/5.8.8/i386- linux-thread-multi/CORE/libperl.so #5 0x00c2a88f in Perl_runops_standard () from /usr/lib/perl5/5.8.8/ i386-linux-thread-multi/CORE/libperl.so #6 0x00bd010e in perl_run () from /usr/lib/perl5/5.8.8/i386-linux- thread-multi/CORE/libperl.so #7 0x0804921e in main () Any help would be great as I'm excited to get spelling correction working. Thanks, Rusty -- Rusty Conover InfoGears Inc. Web: http://www.infogears.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.tartarus.org/pipermail/xapian-devel/attachments/20071216/4d6a7788/attachment.html
On Sun, Dec 16, 2007 at 11:57:15PM -0700, Rusty Conover wrote:> my $db = Search::Xapian::WritableDatabase->new("test.db", > Search::Xapian::DB_CREATE_OR_OPEN); > if (!defined($db)) { > die("Failed to open xapian_database: $!"); > } > my $indexer = Search::Xapian::TermGenerator->new(); > $indexer->set_flags(Search::Xapian::FLAG_SPELLING);You need to add this line here so that the TermGenerator object knows which database to add spellings to: $indexer->set_database($db); But a SEGV is undesirable. I'll see if I can fix that. Cheers, Olly