[9] RFR(S): 8005873: JRuby test_respond_to.rb asserts with: MT-unsafe modification of inline cache

Remi Forax forax at univ-mlv.fr
Fri May 16 15:48:56 UTC 2014


On 05/16/2014 05:22 PM, Paul Sandoz wrote:
> On May 16, 2014, at 5:05 PM, Remi Forax <forax at univ-mlv.fr> wrote:
>
>> On 05/16/2014 01:56 PM, Tobias Hartmann wrote:
>>> Hi,
>>>
>>> thanks to everyone for the feedback.
>>>
>>> Is it sufficient then to use synchronized (lambdaForms) { ... } in setCachedLambdaForm(..) and a normal read in cachedLambdaForm(..)?
>>>
>>> Thanks,
>>> Tobias
>> no, it's not,
>> The memory model doesn't guarantee that a normal read will see that another thread has changed the array item,
>> the normal read may always see null.
>>
>> You need a synchronized block around the normal read.
>>
> I don't think that is required since the pattern is:
>
>    form = cachedLambdaForm(which);
>    if (form != null) return form
>    ...
>    form = /new form/
>    ...
>    form = setCachedLambdaForm(which, form);
>    return form;
>
> and the setCachedLambdaForm will, within it's the synchronized block, first perform a read to check if there is already a non-default value present.
>   
> Paul.

Ok, got it,
it should work :)

cheers,
Rémi




More information about the core-libs-dev mailing list