Top stack frame missing for NPEs

Project:JNode Core
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

In method loadImage() of Desktop class, when I give an invalid image file, I get a stacktrace with a NullPointerException and the message "NPE at address xxxxxxxx" (see the joined screenshot)
The bug is that there is no information about the exact place of the error in the source code (class, method, line number)

I also found such error in other places in JNode. So, in my opinion, it's due an improper handling of NPE (and maybe some other exception) in the VM. I wonder if that's not due to the JIT that loose the information (maybe for the case of inlined methods).

Here is the source code where the error happened :


ByteArrayInputStream bin = new ByteArrayInputStream(out.toByteArray());
BufferedImage img = ImageIO.read(bin);
// here img is null and the NPE error will happen in the following line
BufferedImage ret = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_ARGB);
img.copyData(ret.getRaster());
return img;

AttachmentSize
issues_2415.08 KB

#1

Status:active» closed

It's duplicate with that bug : http://www.jnode.org/node/1582.

#2

will be fixed with that bug

#1

Title:In method loadImage() of Desktop class, wh» Top stack frame missing for NPEs
Priority:normal» critical
Status:closed» active

Actually, we think that this issue is not the same as issue #1582. This one is about the top stack frame being missing. The other one is about missing line numbers on all stack frames.

So I'm reactivating this issue and changing its title to make it more visible. And since this bug is a significant "pain point" for people debugging JNode code, I'm marking it as "critical".

#2

Just to clarify, this only has to do with NPEs being thrown from inside the core of jnode. If you throw an NPE from within the code, the stack frame prints fine.

#3

Status:active» fixed

Fixed it!!! The problem was in VmThread.getStackTrace() in the code that tried to figure out which of the VmStackFrame instances at the top of the stack to hide from the StackTraceElement array used by Throwable printStackTrace(). It was assuming that the top frame captured should always be discarded ... not true for a system exception.

Marking as fixed.

#4

Status:fixed» closed