|Subject:||Segmentation fault in global destruction|
Hi This module will sometimes crash with a segmentation fault on global destruction of variables on program termination. The bug is in the way Perl objects store references to other Perl objects they depend on. Some objects should not be destroyed by the interpreter while a particular object is still alive that depends on them. For example an IndexSearcher object should always be destroyed before a Store object that was used to create it. This is currently done by storing a RVs to Store object in the IndexSearcher object, but this only works correctly while interpreter is running. On global variable destruction the order of object destruction is still not deterministic. A similar problem in another module with the same cause is described in greater detail here:I'm attaching two files: crash2.pl is a test case that causes the segmentation fault on my machine (Debian Lenny, Perl 5.10.0, i386). Since the order of destruction depends on hash ordering, the bug seemingly disappears on minor changes to the code (like adding a new global variable, etc.) lucene_global_destruction.patch is a patch that fixes this bug for me. It follows advice that is given in the post I linked above.
Message body is not shown because it is too large.
#!/usr/bin/perl -w use Lucene; my $store = Lucene::Store::FSDirectory->getDirectory("/home/avian/ft/index", 0); $searcher = Lucene::Search::IndexSearcher->new($store); my $analyzer = Lucene::Analysis::Standard::StandardAnalyzer->new;