java -server buggy? Random NullPointerExcpetions!

M

Markus Dehmann

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
 
T

Thomas Weidenfeller

Markus said:
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.lang.java.help/browse_frm/thread/976ecf5c4f734cb7

See also:

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

/Thomas
 
C

Chris Uppal

Markus said:
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
 
R

Roedy Green

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.
 
Z

zero

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.
 
M

Markus Dehmann

Chris said:
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
 
M

Markus Dehmann

Thomas said:
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
 
R

Roedy Green

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top