Null Pointer Exception - 3rd Gen Tree

Jump to navigation Jump to search

Null Pointer Exception - 3rd Gen Tree


Getting an occasional null pointer exception. I've not worked out why its happening, and looking at the source I can't quite see how it could happen. Call stack looks like

at KDTree.KdNode.addLeafPoint( at KDTree.KdNode.splitLeafNode( at KDTree.KdNode.addLeafPoint( at KDTree.KdNode.addPoint( at KDTree.KdTree.addPoint(

Any ideas?

Wolfman00:45, 26 March 2013

Seems that the "points" array is getting set to 'null' in a newly created child node. Assuming you haven't modified the code of the tree, and you're not doing any multithreading things, I can only see one possible cause: *All* of the data points are being put in the same child node, causing the newly created child node to itself be split while the upper level's splitLeafNode is still running. This implies that calculateSplit() is returning true when it shouldn't.

Could you add code to line 169 to print the list of coordinates stored in the node being split, or use a debugger to obtain similar information? My suspicion is that the coordinates you're putting into the tree are very unusual in some manner, possibly involving NaN values.

Rednaxela01:28, 26 March 2013

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

Return to Thread:User talk:Rednaxela/kD-Tree/Null Pointer Exception - 3rd Gen Tree/reply (2).


The last point there is null...

AW15:50, 26 March 2013

Yes but its index 49, and size is currently 48. :)

Wolfman16:06, 26 March 2013

Yeah, that null there is not a problem, though it does look like I accidentally made the nodes split one entry too early. That wouldn't cause any issue besides a tiny amount of wasted memory though.

Later today I'll see if I can replicate the issue with that list of points.

Rednaxela16:30, 26 March 2013