hi all, With Clucene v2.3.3.4, I found something strange in SloppyPhraseScorer.cpp:
1. repeats[repeatsLen + 1] = NULL; // NULL terminate the array Is it a mistake? repeats was allocated like this: repeats = _CL_NEWARRAY(PhrasePositions*, repeatsLen + 1); 2. qsort(repeats, repeatsLen, sizeof(PhrasePositions*), comparePhrasePositions); After qsort, repeats is still unordered, and valgrind complains: ==20998== Invalid read of size 4 ==20998== at 0x6A4AF2E: lucene::search::SloppyPhraseScorer::comparePhrasePositions(void const*, void const*) (_SloppyPhraseScorer.h:50) ==20998== by 0x245F65: msort_with_tmp (in /lib/libc-2.5.so) ==20998== by 0x245F21: msort_with_tmp (in /lib/libc-2.5.so) ==20998== by 0x246436: qsort (in /lib/libc-2.5.so) ==20998== by 0x6A4A9AE: lucene::search::SloppyPhraseScorer::initPhrasePositions() (SloppyPhraseScorer.cpp:136) ==20998== by 0x6A4ABE8: lucene::search::SloppyPhraseScorer::phraseFreq() (SloppyPhraseScorer.cpp:42) ==20998== by 0x6A498E0: lucene::search::PhraseScorer::doNext() (PhraseScorer.cpp:92) ==20998== by 0x6A4A17D: lucene::search::PhraseScorer::next() (PhraseScorer.cpp:79) ==20998== by 0x6A4CBBA: lucene::search::ConjunctionScorer::init(int) (ConjunctionScorer.cpp:92) ==20998== by 0x6A4CD66: lucene::search::ConjunctionScorer::next() (ConjunctionScorer.cpp:54) ==20998== by 0x6A53CB2: lucene::search::BooleanScorer2::score(lucene::search::HitCollector*) (BooleanScorer2.cpp:629) ==20998== by 0x6A62AEF: lucene::search::IndexSearcher::_search(lucene::search::Query*, lucene::search::Filter*, int) (IndexSearcher.cpp:242) ==20998== by 0x6A6766D: lucene::search::Hits::getMoreDocs(unsigned int) (Hits.cpp:120) ==20998== by 0x6A67B67: lucene::search::Hits::Hits(lucene::search::Searcher*, lucene::search::Query*, lucene::search::Filter*, lucene::search::Sort const*) (Hits.cpp:60) ==20998== by 0x6A60C17: lucene::search::Searcher::search(lucene::search::Query*, lucene::search::Filter*) (SearchHeader.cpp:188) ==20998== by 0x6A60C5B: lucene::search::Searcher::search(lucene::search::Query*) (SearchHeader.cpp:184) If use std::sort instead qsort, everything works well, repeats is ordered and valgrind doesn't complain. Is it qsort's problem? Thanks Eli ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ CLucene-developers mailing list CLucene-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/clucene-developers