On 28/6/2010 10:48 PM, Kostka Bořivoj wrote:
> I did some tests with cl_demo and found following:
>
> In DocumentsWriter destructor postingsFreeCountDW is 5888 and the length of  
> postingsFreeListDW.values
> is 7424. Maybe I'm wrong but if I understand the logic implemented in 
> getPostings and recyclePostings well,
> the postingsFreeListDW.values above postingsFreeCountDW shouldn't be 
> considered a valid pointers
> But they are by ArrayBase destructor, and delete attempt can (and will) cause 
> crash.
>
> To test this, I simply added (yes it might be done more efficient way using 
> memset)
>
> for ( size_t i = this->postingsFreeCountDW; i<  
> this->postingsFreeListDW.length; i++ ){
>       this->postingsFreeListDW.values[i] = NULL;
>   }
>
> and cl_demo runs correctly.
>
> Of course I could miss something important in code and produce memory leaks 
> instead of fixing bug....
>    

NULLifying alone is not the right solution, as it will leak memory. The 
_CLDELETE macro also sets that position in the array to NULL after 
deleting it, so your conclusion is incorrect.

The only reason why cl_demo runs correctly with your change is it 
prevents double deletion. Exactly what I said we should trace and fix...

postingsFreeListDW is ObjectArray, which deletes its value and the 
pointers contained within it. I would very much like to keep it this 
way and find why the values in it are being deleted twice (and from 
where), instead of transofrming it into ValueArray. Perhaps placing it 
on the heap instead of on the stack and deleting + NULLifying the actual 
postingsFreeListDW on destructor will do this?

Itamar.

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers

Reply via email to