[stringtemplate-interest] thread-safety issue in ST-4.0.4

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Thu Nov 24 09:13:10 PST 2011


You shouldn't need to manually synchronise, necessarily, depending on 
the algorithm structure, I believe there's a synchronising tree wrapper 
in the standard library. Of course, if multiple linked adds happen that 
should be atomic, you'll need to synchronize externally or restructure 
things...

Of course, you probably know all this, but just in case ;)

Sam

On 24/11/2011 16:44, Terence Parr wrote:
> yikes. let me take a look.
> T
> On Nov 24, 2011, at 1:41 AM, Oliver Flege wrote:
>
>>
>> Hi,
>>
>> I just found out the hard way that
>> org.stringtemplate.v4.misc.ObjectModelAdaptor ist not thread-safe:
>>
>> The field classAndPropertyToMemberCache can be accessed by multiple
>> threads at the same time.
>> Since org.antlr.runtime.misc.DoubleKeyMap and its internal
>> java.util.LinkedHashMap aren't thread-safe, parallel puts might
>> corrupt the map's structure (in my case: the pointers to the next
>> Entry ended up forming an infinite loop).
>>
>> classAndPropertyToMemberCache.get/put should be synchronized on
>> a common mutex object.
>>
>> Regards,
>> Oliver
>>
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest


More information about the stringtemplate-interest mailing list