[DGD] LWO Behavior in mappings

Par Winzell zell at skotos.net
Tue May 20 18:32:52 CEST 2003


Jay,

> The problem is that I was using a lightweight object as the index into 
> the mapping, and these mapping entries were living beyond the end of the 
> current thread.  Further, the mapping lived in a different object than 
> the one that had the original reference to the lightweight object.  So 
> at the end of the thread, the lightweight object in the mapping was 
> copied.  In a later thread, I would check to see if the lightweight 
> object existed in the mapping yet...since it had been copied, the answer 
> was always no, and I would create a new entry for it, which created yet 
> another copy at the end of the thread, etc.  Multiply this by a hundred 
> lightweight objects, and you can reach 10,000 entries in a fairly small 
> number of threads.
> 
> It seems that the moral is to not use lightweight objects as indices 
> into mappings, except in limited circumstances.

Right. And not just lightweight objects. And not just indices in a 
mapping. Anytime you get an array, mapping or LWO from another object 
and store it past the end of a thread, all direct pointer comparisons to 
those objects have undefined behaviour.

Easy to say, sometimes hard to really burn into your cortex.

Zell


_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list