Intermittent NullPointerExceptions

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Intermittent NullPointerExceptions

Jeff Hennick-3

This may be a problem with me, or NetRexx or Pipes.

I am writing comprehensive tests for the pipes stages.  And finding some errors in the current stage routines.  In this testing I am having intermittent problems with some code.  That is, I can sometimes run it and it works, then immediately run it again (using the up arrow and ENTER) and it throws errors, specifically NullPointerException.  In multiple runs, it will sometimes work and sometimes give the errors.

I believe I have put in full redundant protection to prevent any NULLs at all.  Also there are several lines here for "instrumentation" and diagnosis.

Here is the snippet in question from cons_new.nrx (the updated, because of these errors, version of the CONSOLE stage):

      loop forever
         line = peekto()
         if line = null then do                             -- These "traps" for nulls never catch anything
            say 'Null'
         end
         if line = null then line = '???'
         say line
         output(line)
         readto()
      catch NullPointerException
         say '*******************************************'
      catch StageError
         rc = rc()
      finally
         say 'Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
      end
These are a part of the output and error messages I get (there are two threads running in here):

90 *=* loop forever 91 *=* line = peekto() >v> line "0003Kim" 92 *=* if line = null --- cons_new.nrx [Thread-35,njPipes] 91 >v> line "0007debby" 92 *=* if line = null >>> "0" 95 *=* if line = null >>> "0" --- cons_new.nrx [Thread-95,njPipes] 92 >>> "0" 95 *=* if line = null >>> "0" 96 *=* say line >>> "0003Kim" --- cons_new.nrx [Thread-35,njPipes] 96 *=* say line >>> "0007debby" 0007debby 0003Kim 99 *=* catch NullPointerException 100 *=* say '*******************************************' >>> "*******************************************" ******************************************* --- cons_new.nrx [Thread-95,njPipes] 99 *=* catch NullPointerException --- cons_new.nrx [Thread-35,njPipes] 103 *=* finally 104 *=* say 'Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' >>> "Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --- cons_new.nrx [Thread-95,njPipes] 100 *=* say '*******************************************' >>> "*******************************************" ******************************************* java.lang.NullPointerException at java.util.LinkedList$ListItr.next(Unknown Source) at netrexx.lang.RexxIO.Say(RexxIO.java:121) at netrexx.lang.RexxIO.Say(RexxIO.java:93) at cons_new.run(cons_new.java:105) at org.netrexx.njpipes.pipes.ThreadPool.run(ThreadPool.java:76) at java.lang.Thread.run(Unknown Source)
Note the error line is cons_new.java.105.  That is the "end" statement.  Actually, if there is another line in the finally block before the end, that is the line reported to have a null.  But if there is no finally block at all, the error line is up in the catch block.

Any help in locating my error would greatly be appreciated.  I have lost many hours over the course of weeks going around on this.

Jeff Hennick



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jason Martin
Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jason Martin
In reply to this post by Jeff Hennick-3
SpotBugs is good too.

I know there is at least one Null exception in the nrl runtime.

https://urldefense.proofpoint.com/v2/url?u=https-3A__spotbugs.github.io_&d=DwICaQ&c=jf_iaSHvJObTbx-siA1ZOg&r=_6rXNpPJ1fYV-3bV1za02NiR4PUelvicfHXwtnTXpXE&m=Ske3ZGRGbJ-OZXq6rJFCPRaXTGZAmSmsSBAtaf_LpQc&s=55FfAUqxM8TueoxHlRvtm2vhVv_7tnGZwjUZibTGHYs&e= 

Adding the fb-contrib part too.


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jason Martin
In reply to this post by Jeff Hennick-3
As a side note, I personally appreciate the time you have put into this.

I just have not had the the time or felt like wrapping my head around
Pipes yet.

I hope to do so in the new year.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

rvjansen
In reply to this post by Jeff Hennick-3
I agree with Jason that it might be a race condition or other threading issue. We might be able to subclass LinkedList and trace what is going on.
On first sight this is caused by an iterator over the linked list that does not find a next item. The threads accessing the linked list should be synchronized; maybe they are not.

If you have checked in the offending pipeline, please let me know which it is.

best regards,

René.

On 27 Dec 2019, at 18:13, Jeff Hennick <[hidden email]> wrote:

This may be a problem with me, or NetRexx or Pipes.

I am writing comprehensive tests for the pipes stages.  And finding some errors in the current stage routines.  In this testing I am having intermittent problems with some code.  That is, I can sometimes run it and it works, then immediately run it again (using the up arrow and ENTER) and it throws errors, specifically NullPointerException.  In multiple runs, it will sometimes work and sometimes give the errors.

I believe I have put in full redundant protection to prevent any NULLs at all.  Also there are several lines here for "instrumentation" and diagnosis.

Here is the snippet in question from cons_new.nrx (the updated, because of these errors, version of the CONSOLE stage):


      loop forever
         line = peekto()
         if line = null then do                             -- These "traps" for nulls never catch anything
            say 'Null'
         end
         if line = null then line = '???'
         say line
         output(line)
         readto()
      catch NullPointerException
         say '*******************************************'
      catch StageError
         rc = rc()
      finally
         say 'Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
      end
These are a part of the output and error messages I get (there are two threads running in here):


90 *=* loop forever 91 *=* line = peekto() >v> line "0003Kim" 92 *=* if line = null --- cons_new.nrx [Thread-35,njPipes] 91 >v> line "0007debby" 92 *=* if line = null >>> "0" 95 *=* if line = null >>> "0" --- cons_new.nrx [Thread-95,njPipes] 92 >>> "0" 95 *=* if line = null >>> "0" 96 *=* say line >>> "0003Kim" --- cons_new.nrx [Thread-35,njPipes] 96 *=* say line >>> "0007debby" 0007debby 0003Kim 99 *=* catch NullPointerException 100 *=* say '*******************************************' >>> "*******************************************" ******************************************* --- cons_new.nrx [Thread-95,njPipes] 99 *=* catch NullPointerException --- cons_new.nrx [Thread-35,njPipes] 103 *=* finally 104 *=* say 'Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' >>> "Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --- cons_new.nrx [Thread-95,njPipes] 100 *=* say '*******************************************' >>> "*******************************************" ******************************************* java.lang.NullPointerException at java.util.LinkedList$ListItr.next(Unknown Source) at netrexx.lang.RexxIO.Say(RexxIO.java:121) at netrexx.lang.RexxIO.Say(RexxIO.java:93) at cons_new.run(cons_new.java:105) at org.netrexx.njpipes.pipes.ThreadPool.run(ThreadPool.java:76) at java.lang.Thread.run(Unknown Source)
Note the error line is cons_new.java.105.  That is the "end" statement.  Actually, if there is another line in the finally block before the end, that is the line reported to have a null.  But if there is no finally block at all, the error line is up in the catch block.

Any help in locating my error would greatly be appreciated.  I have lost many hours over the course of weeks going around on this.

Jeff Hennick


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jason Martin
In reply to this post by Jeff Hennick-3
What happens if you move StageError before NullPointerException?

On 2019-12-27 12:13, Jeff Hennick wrote:
> catch NullPointerException
>          say '*******************************************'
>       catch StageError
>          rc = rc()

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jeff Hennick-3

Thank you for thinking about this.  It is, I'm afraid, too deep for me to explore on my own.

The pipe in this test file is very long -- about 185 stages -- but with no feedback loops.  It has tests for 4 sets of options, with the input data streams and the expected results for all 6 output streams for each of the tests.

When I break these into 4 separate files, they all work individually. (Just now tried again.)

------------------------

with:

         readto()
      catch StageError
         rc = rc()
      catch NullPointerException
         say '*******************************************'
      finally

This is just out of the middle of the output stream when I run a bunch of tests for the LOOKUP stage using CONS_NEW in place of CONSOLE:

--- cons_new.nrx [Thread-35,njPipes] 91 >v> line "0007debby" 92 *=* if line = null >>> "0" 95 *=* if line = null >>> "0" 96 *=* say line >>> "0007debby" 0007debby 0003Kim 101 *=* catch NullPointerException 102 *=* say '*******************************************' >>> "*******************************************" ******************************************* --- cons_new.nrx [Thread-95,njPipes] 101 *=* catch NullPointerException 102 *=* say '*******************************************' >>> "*******************************************" ******************************************* --- cons_new.nrx [Thread-35,njPipes] 103 *=* finally 104 *=* say 'Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' >>> "Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --- cons_new.nrx [Thread-95,njPipes] 103 *=* finally 104 *=* say 'Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' >>> "Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" Finally !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! java.lang.NullPointerException at java.util.LinkedList$ListItr.next(Unknown Source) at netrexx.lang.RexxIO.Say(RexxIO.java:121) at netrexx.lang.RexxIO.Say(RexxIO.java:93) at cons_new.run(cons_new.java:105) at org.netrexx.njpipes.pipes.ThreadPool.run(ThreadPool.java:76) at java.lang.Thread.run(Unknown Source) java.lang.NullPointerException at java.util.LinkedList$ListItr.next(Unknown Source) at netrexx.lang.RexxIO.Say(RexxIO.java:121)Exiting due to uncaught Exception null at netrexx.lang.RexxIO.Say(RexxIO.java:93) at cons_new.run(cons_new.java:105) at org.netrexx.njpipes.pipes.ThreadPool.run(ThreadPool.java:76) at java.lang.Thread.run(Unknown Source) Exception in thread "Thread-95" Exiting due to uncaught Exception null --- cons_new.nrx [Thread-4,njPipes] Exception in thread "Thread-35" java.lang.NullPointerException at java.util.LinkedList$ListItr.next(Unknown Source) at netrexx.lang.RexxIO.Say(RexxIO.java:121) at netrexx.lang.RexxIO.Say(RexxIO.java:93) at org.netrexx.njpipes.pipes.ThreadPool.run(ThreadPool.java:108) at java.lang.Thread.run(Unknown Source) java.lang.NullPointerException at java.util.LinkedList$ListItr.next(Unknown Source) at netrexx.lang.RexxIO.Say(RexxIO.java:121) at netrexx.lang.RexxIO.Say(RexxIO.java:93) at org.netrexx.njpipes.pipes.ThreadPool.run(ThreadPool.java:108) at java.lang.Thread.run(Unknown Source)

It goes on with many more similar exceptions.

So, to answer your question, it fails with the CATCHes in either order.

On 12/28/2019 8:27 PM, Jason Martin wrote:
What happens if you move StageError before NullPointerException?

On 2019-12-27 12:13, Jeff Hennick wrote:
catch NullPointerException
         say '*******************************************'
      catch StageError
         rc = rc()

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jason Martin
In reply to this post by Jeff Hennick-3
One other option that I posted the other day that did not go through to
the list.

add at the right place in the NetRexx build.xml


debug="on" debuglevel="lines,vars,source"


This may provide info you need.



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Intermittent NullPointerExceptions

Jeff Hennick-3

I'll need a lot more help with this.  This is the first time I have seen a build.xml, much less added something somewhere.  (I just now looked at it.)  [My background is as a Rexx jockey, and a very little, simple, Java..]

Thanks.

On 12/28/2019 9:28 PM, Jason Martin wrote:
One other option that I posted the other day that did not go through to the list.

add at the right place in the NetRexx build.xml


debug="on" debuglevel="lines,vars,source"


This may provide info you need.



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/