Markus Wörle
2008-Jan-14 20:46 UTC
[Xapian-discuss] Visibility Problem in Perl Bindings for MultiValueSorter
Hi again, I recently discovered that { my $sorter = new Search::Xapian::MultiValueSorter(1,2); $enq->set_sort_by_key($sorter); } my $mset = $enq->get_mset(0, 5); segfaults in get_mset(), but my $sorter; { $sorter = new Search::Xapian::MultiValueSorter(1,2); $enq->set_sort_by_key($sorter); } my $mset = $enq->get_mset(0, 5); works well. I think there is a visibility-problem in the XS or C++ code. Looks like the $enq object just contains a reference on the sorter, and as soon as the referee becomes invisible it breaks. Regards, mrks
Olly Betts
2008-Jan-24 02:46 UTC
[Xapian-discuss] Visibility Problem in Perl Bindings for MultiValueSorter
On Mon, Jan 14, 2008 at 09:46:07PM +0100, Markus W?rle wrote:> { > my $sorter = new Search::Xapian::MultiValueSorter(1,2); > $enq->set_sort_by_key($sorter); > } > my $mset = $enq->get_mset(0, 5); > > segfaults in get_mset(), [...] > > I think there is a visibility-problem in the XS or C++ code. Looks > like the $enq object just contains a reference on the sorter, and as > soon as the referee becomes invisible it breaks.Yes - the C++ reference counting system we currently use doesn't allow us to reference count user-subclassable classes so Xapian::Sorter isn't reference counted by Xapian itself. I've fixed this for now the way Search::Xapian handles similar cases, which is to increment the reference count and deliberately leak the Sorter object. Not ideal, but the best we can easily do right now. There's a bug open for the underlying issue: http://www.xapian.org/cgi-bin/bugzilla/show_bug.cgi?id=186 Cheers, Olly