You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Jochen Theodorou <bl...@gmx.org> on 2015/06/07 12:57:24 UTC

Re: NPE exception on ManagedLinkedList

Am 29.05.2015 15:15, schrieb Paolo Di Tommaso:
> Dear all,
>
> Upgrading to Groovy 2.4.3 I've started to experience a
> NullPointerException that is raised somehow randomly.

The source code line is:

>             if (previous != null && previous.next != null) {

this can cause a NPE if there is a data race... funny thing is, the 
comment of the class says:

>  * This class does not support concurrent modifications nor will it check
>  * for them. This class is also not thread safe.

Which strongly suggests, that the class is not used as intended

hmm... the entry points look right... that can only mean that it is the 
ReferenceManager re-usage, that is causing trouble here.

bye blackdrag

-- 
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/


Re: NPE exception on ManagedLinkedList

Posted by Paolo Di Tommaso <pa...@gmail.com>.
OK, but if so it looks to me that is a Groovy runtime issue, isn't it?


Cheers, p

On Sun, Jun 7, 2015 at 4:11 PM, Jochen Theodorou <bl...@gmx.org> wrote:

> Am 07.06.2015 15:49, schrieb Paolo Di Tommaso:
>
>> Well, the point it that I'm not using any ManagedLinkedList object in my
>> code.
>>
>> At a first look it seems to me a side effect of this change:
>>
>> https://issues.apache.org/jira/browse/GROOVY-6704
>>
>
> the change made it maybe obvious, but the problem is deeper.
>
> ManagedLinkedList uses a reference manager, which will check elements of
> the list if they are still exist, since the elements are weak or soft
> referenced usually. This manager could be in a thread, but in groovy-core
> it is normally just triggered every now and then. Now, one manager handles
> one ReferenceQueue, but in theory multiple lists can share the same
> multiple manager. Now if the cleanup process is triggered by multiple lists
> "at the same time", there might be multiple threads operating the same
> manager and same ReferenceQueue. I assume it is a situation like that,
> which you experience. Solution are obviously that those lists each have
> their own manager or that the manager adds some synchronization to avoid
> this situation. Not sure yet what the best approach is
>
>
> bye blackdrag
>
> --
> Jochen "blackdrag" Theodorou
> blog: http://blackdragsview.blogspot.com/
>
>

Re: NPE exception on ManagedLinkedList

Posted by Jochen Theodorou <bl...@gmx.org>.
Am 07.06.2015 15:49, schrieb Paolo Di Tommaso:
> Well, the point it that I'm not using any ManagedLinkedList object in my
> code.
>
> At a first look it seems to me a side effect of this change:
>
> https://issues.apache.org/jira/browse/GROOVY-6704

the change made it maybe obvious, but the problem is deeper.

ManagedLinkedList uses a reference manager, which will check elements of 
the list if they are still exist, since the elements are weak or soft 
referenced usually. This manager could be in a thread, but in 
groovy-core it is normally just triggered every now and then. Now, one 
manager handles one ReferenceQueue, but in theory multiple lists can 
share the same multiple manager. Now if the cleanup process is triggered 
by multiple lists "at the same time", there might be multiple threads 
operating the same manager and same ReferenceQueue. I assume it is a 
situation like that, which you experience. Solution are obviously that 
those lists each have their own manager or that the manager adds some 
synchronization to avoid this situation. Not sure yet what the best 
approach is

bye blackdrag

-- 
Jochen "blackdrag" Theodorou
blog: http://blackdragsview.blogspot.com/


Re: NPE exception on ManagedLinkedList

Posted by Paolo Di Tommaso <pa...@gmail.com>.
Well, the point it that I'm not using any ManagedLinkedList object in my
code.

At a first look it seems to me a side effect of this change:

https://issues.apache.org/jira/browse/GROOVY-6704


Does that make sense ?


Cheers,
Paolo



On Sun, Jun 7, 2015 at 12:57 PM, Jochen Theodorou <bl...@gmx.org> wrote:

> Am 29.05.2015 15:15, schrieb Paolo Di Tommaso:
>
>> Dear all,
>>
>> Upgrading to Groovy 2.4.3 I've started to experience a
>> NullPointerException that is raised somehow randomly.
>>
>
> The source code line is:
>
>              if (previous != null && previous.next != null) {
>>
>
> this can cause a NPE if there is a data race... funny thing is, the
> comment of the class says:
>
>   * This class does not support concurrent modifications nor will it check
>>  * for them. This class is also not thread safe.
>>
>
> Which strongly suggests, that the class is not used as intended
>
> hmm... the entry points look right... that can only mean that it is the
> ReferenceManager re-usage, that is causing trouble here.
>
> bye blackdrag
>
> --
> Jochen "blackdrag" Theodorou
> blog: http://blackdragsview.blogspot.com/
>
>