Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Impossible (?): NullPointerException on ConcurrentLinkedQueue.size()

I'm getting this NPE on IBM JVM, 1.6:

java.lang.NullPointerException at java.util.concurrent.ConcurrentLinkedQueue.first(ConcurrentLinkedQueue.java:274) at java.util.concurrent.ConcurrentLinkedQueue.size(ConcurrentLinkedQueue.java:315) . . .

Relevant source shows that line #274 throws on a null "head" member. Search for usages shows this member is set to a new node() as needed, but is never nullified.

How could that be? What am I missing?

... I cannot reproduce this when in debug mode. This queue is accessed from multiple threads.

Snippet (Sun&IBM sources identical except for comments that change line numbers a bit):

     Node<E> first() {
                for (;;) {
                    Node<E> h = head;
                    Node<E> t = tail;
                    Node<E> first = h.getNext(); // line #274 on IBM, #263 on Sun
...
    }
    }
like image 491
adaf Avatar asked Sep 14 '26 06:09

adaf


1 Answers

Errors like that often come from the JIT compiler which gets some arcane optimization wrong.

There is little you can do; log error with IBM, they will then guide you through the process how to collect enough information for them to debug the issue.

Note: In the last years, we filed two such issues. So they aren't that uncommon even taking into account the enormous testing effort that IBM spends on their VM.

like image 98
Aaron Digulla Avatar answered Sep 16 '26 19:09

Aaron Digulla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!