NodeNotFound Octree Crashes
tpwrules opened this issue · 5 comments
I am trying to build an octree from a point cloud with the following header:
ply
format binary_little_endian 1.0
element vertex 186546528
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
end_header
Using the latest build from master as of the time of this ticket submission, the program crunches for a minute or so then dies because it tries to unwrap a NodeNotFound error. The full traceback is here: https://pastebin.com/mWXkRpWh
Unfortunately, the data is a) several gigabytes and b) not to be made available according to my superiors. But I have done some research which might aid in reproducing the issue with another dataset.
This block seems to be the issue: https://github.com/googlecartographer/point_cloud_viewer/blob/a88f232bbbee12bb343432e61afe64e91b0073fb/src/generation.rs#L170-L179
If the node child_id
does not exist, the code will notice that the return from octree::NodeIterator::from_data_provider
is a NodeNotFound
error and skip processing that node. But the call to octree_data_provider.number_of_points(&child_id)
will also return NodeNotFound
in that case and unwrapping that with ?
will crash the program.
I stopped the crashing by separately matching the number_of_points result:
let number_of_points = match octree_data_provider.number_of_points(&child_id) {
Ok(number_of_points) => number_of_points,
Err(Error(ErrorKind::NodeNotFound, _)) => continue,
Err(err) => return Err(err),
};
let node_iterator = match octree::NodeIterator::from_data_provider(
octree_data_provider,
octree_meta,
&child_id,
number_of_points,
) {
Ok(node_iterator) => node_iterator,
Err(Error(ErrorKind::NodeNotFound, _)) => continue,
Err(err) => return Err(err),
};
I'm not sure whether this fix is complete, but it seems to make everything work as I would expect and I get a nice view in my web browser when I spin up the server. There is another function that calls number_of_points
which may have the same problem. I wonder if it's because the system deletes nodes with 0 points:
https://github.com/googlecartographer/point_cloud_viewer/blob/a88f232bbbee12bb343432e61afe64e91b0073fb/src/octree/node.rs#L477-L487
If necessary, I can try to create a dataset that's problematic, but I hope this is enough information to solve the problem.
That seems a plausible analysis, thanks for providing that. A failing dataset would be wonderful, so we could build and check in a regression test.
@feuerste We should plan this bug fix in our system as P2. could you take this one?
I took it over and will have a look soon.
@tpwrules Thanks a lot for the bug report and the detailed explanation.
I just reproduced the error and created a PR #211 to fix it.
The second method using number_of_points
is actually unaffected, because it knows exactly which children exist and only works on these, so unwrap
is safe in this case.