Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java -server buggy? Random NullPointerExcpetions!

Reply
Thread Tools

java -server buggy? Random NullPointerExcpetions!

 
 
Markus Dehmann
Guest
Posts: n/a
 
      10-07-2005
I just wasted hours and hours finding the source of a
NullPointerException I was getting.

It turns out the "java -server" switch causes such a NullPointerException.

My application reads in 40,000 text lines and processes them. The
tricky thing is that the NullPointerException occurs every time on a
different input line.

I nearly got insane. But now I know it's "java -server"'s fault.

I tested it with java 1.4.2_01 and 1.5.0_03-b07 on Redhat Linux. And
everytime I use -server I get the exception.

Is this a known bug?

Another thing that made me insane is that the exception *never* occured
on my Mac, with java 1.4.2-54, no matter if I used -server or not.

BTW, I read the input from a FileInputStream. Should I better use
something Buffered...?

Thanks!
Markus
 
Reply With Quote
 
 
 
 
hiwa
Guest
Posts: n/a
 
      10-07-2005
Code please. See:
http://www.physci.org/codes/sscce.jsp

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      10-07-2005
Markus Dehmann wrote:
> My application reads in 40,000 text lines and processes them. The
> tricky thing is that the NullPointerException occurs every time on a
> different input line.
>
> I nearly got insane. But now I know it's "java -server"'s fault.


No, with a very high probability it is not. With a very high probability
you messed up some thread handling. The problem is exposed by some VMs,
but not by others.

> Is this a known bug?


Check Sun's bug parade by your own if you really think this is a bug in
the VM.

> BTW, I read the input from a FileInputStream. Should I better use
> something Buffered...?


How should we know? You didn't show us your code. You didn't show us the
exact exception, including the stack trace. You just ranted a little bit
about an assumed bug. Just a few days such behavior was discussed her:

http://groups.google.com/group/comp....6ecf5c4f734cb7

See also:

http://www.catb.org/~esr/faqs/smart-...html#id3001405

/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
http://www.uni-giessen.de/faq/archiv....java.gui.faq/
 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      10-07-2005
Markus Dehmann wrote:

> I tested it with java 1.4.2_01 and 1.5.0_03-b07 on Redhat Linux. And
> everytime I use -server I get the exception.
>
> Is this a known bug?


Quite possibly. The server VM uses different (more aggressive) optimisation,
and if there's every been an optimising code generator that lacks bugs then I
have yet to hear of it


> BTW, I read the input from a FileInputStream. Should I better use
> something Buffered...?


Very definitely you should. Indeed, given the size of your files, I would say
that you /must/ use buffering of some sort, either with a BufferedReader or by
doing it yourself.

BTW, someone mentioned a problem some time ago, where they were encountering
random errors reading lots of data unbuffered on a Linux system. It may be
that there's some subtle bug somewhere in the software stack (including any
code included in the disk's own controller) which is exposed by doing many,
many, many, tiny reads at the OS/hardware level. So there's a /chance/ (albeit
small) that using proper buffering in your code would also side-step the
problem you are seeing with -server.

-- chris



 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-07-2005
On Fri, 07 Oct 2005 04:09:33 -0400, Markus Dehmann
<(E-Mail Removed)> wrote or quoted :

>Is this a known bug?


see http://mindprod.com/jgloss/bugs.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-07-2005
On Fri, 07 Oct 2005 04:09:33 -0400, Markus Dehmann
<(E-Mail Removed)> wrote or quoted :

>BTW, I read the input from a FileInputStream. Should I better use
>something Buffered...?


I know you are frustrated but in your frustration the only clue you
have given us is that the problem SOMETIMES shows up. That is it.
That is all WE have to go on.

That is like going to the doctor and saying "I have a problem that
sometimes shows up most often when I wear my red jacket. I won't tell
you anything more or let you run any tests, or let you look at my
body." What is the matter with me??

The only generic advice I can give is that problems that sometimes
show up are nearly always something to do with threads.

See http://mindprod.com/jgloss/threads.html
http://mindprod.com/jgloss/threadsafe.html
http://mindprod.com/jgloss/volatile.html
http://mindprod.com/jgloss/synchonized.html

For more specific help we have to see the code. At the very least we
have to see the stack trace and the code relevant to the stack trace.

-server is going to make bad thread code fail faster since
optimisation spreads logic out over time.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
zero
Guest
Posts: n/a
 
      10-07-2005
Roedy Green <(E-Mail Removed) > wrote in
news:(E-Mail Removed):

>
> That is like going to the doctor and saying "I have a problem that
> sometimes shows up most often when I wear my red jacket. I won't tell
> you anything more or let you run any tests, or let you look at my
> body." What is the matter with me??
>


You're allergic to red. That'll be $15. Have a nice day.
 
Reply With Quote
 
Markus Dehmann
Guest
Posts: n/a
 
      10-07-2005
Chris Uppal wrote:
> Markus Dehmann wrote:
>
>>BTW, I read the input from a FileInputStream. Should I better use
>>something Buffered...?

>
> Very definitely you should. Indeed, given the size of your files, I would say
> that you /must/ use buffering of some sort, either with a BufferedReader or by
> doing it yourself.


I double-checked it: I am calling a method in an external library,
passing an InputStream, but the library actually wraps it into a
BufferedReader, internally. So, that's not the reason for the failures
after all.

Thanks
Markus
 
Reply With Quote
 
Markus Dehmann
Guest
Posts: n/a
 
      10-07-2005
Thomas Weidenfeller wrote:
> Markus Dehmann wrote:
>
> How should we know? You didn't show us your code. You didn't show us the
> exact exception, including the stack trace. You just ranted a little bit
> about an assumed bug.


Sorry, I can't show the code since the NullPointerExceptions occur in an
external library that I am using. I do have the source, but it's hard
to construct a minimal example from it. So, after all I've read here it
might be that a Thread in that library is not safe.

Markus
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-08-2005
On Fri, 07 Oct 2005 17:19:34 -0400, Markus Dehmann
<(E-Mail Removed)> wrote or quoted :

>Sorry, I can't show the code since the NullPointerExceptions occur in an
>external library that I am using. I do have the source, but it's hard
>to construct a minimal example from it.


If you can't do that, show at least some context around the exception.
Even knowing the type of the reference can be a big clue. Knowing
what methods you called just prior to the exceptions, or the method
you called to create the bad reference help.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Random not really random... Maziar Aflatoun ASP .Net 4 08-05-2004 01:26 AM
Random NOt random? Darren Clark ASP .Net 3 06-24-2004 05:23 PM
Searching Example-Code for J2ME - creating Random Integers via java.util.Random() Elmar Baumann Java 0 02-02-2004 08:32 PM



Advertisments