PDAL / python

PDAL's Python Support
Other
115 stars 34 forks source link

Segfault with filters.poisson executed twice #128

Open floriandeboissieu opened 1 year ago

floriandeboissieu commented 1 year ago

With pdal=2.4.1 and python-pdal=3.1.2 (same happens with pdal=2.4.3 & python-pdal=3.2.0), when executing twice the same command I get a segfault.

import pdal
data = "https://github.com/PDAL/PDAL/blob/master/test/data/las/1.2-with-color.las?raw=true"
stages = [pdal.Reader.las(filename=data), pdal.Filter.poisson()]
pdal.Pipeline(stages).execute()

stages = [pdal.Reader.las(filename=data), pdal.Filter.poisson()]
pdal.Pipeline(stages).execute()

It was tested with Filter.delaunay and there is not such a behavior.

hobu commented 1 year ago

Confirmed, but I'm not sure what to do about it. The noding code in the khazdan poisson software appears to be the issue. The tree building code in there must have something with a global state that's not being cleaned up.

    frame #174651: 0x00000001021bcb2c libpdalcpp.14.3.0.dylib`double Octree<double>::_getSamplesPerNode<2, PointSupportKey<2> >(Octree<double>::DensityEstimator const&, OctNode<TreeNodeData> const*, Point3D<double>, PointSupportKey<2>&) const + 84
    frame #174652: 0x00000001021bbef0 libpdalcpp.14.3.0.dylib`double Octree<double>::_splatPointData<true, 2, 2, Point3D<double> >(Octree<double>::DensityEstimator const&, Point3D<double>, Point3D<double>, SparseNodeData<Point3D<double> >&, PointSupportKey<2>&, PointSupportKey<2>&, int, int, int) + 384
    frame #174653: 0x00000001021bbc48 libpdalcpp.14.3.0.dylib`SparseNodeData<Point3D<double> > Octree<double>::setNormalField<2, 2>(std::__1::vector<Octree<double>::PointSample, std::__1::allocator<Octree<double>::PointSample> > const&, Octree<double>::DensityEstimator const&, double&, bool) + 464
    frame #174654: 0x00000001021b8b78 libpdalcpp.14.3.0.dylib`PoissonRecon<double>::calcNormalData() + 56
abellgithub commented 1 year ago

A full stack trace would be helpful.

hobu commented 1 year ago
import pdal
data = "https://github.com/PDAL/PDAL/blob/master/test/data/las/1.2-with-color.las?raw=true"
stages = [pdal.Reader.las(filename=data), pdal.Filter.poisson()]
pdal.Pipeline(stages).execute()

stages = [pdal.Reader.las(filename=data), pdal.Filter.poisson()]
pdal.Pipeline(stages).execute()
    frame #1: 0x0000000102e90cf4 libpdalcpp.14.3.0.dylib`PoissonRecon<double>::trim() + 56
    frame #2: 0x0000000102e8de0c libpdalcpp.14.3.0.dylib`PoissonRecon<double>::execute() + 360
    frame #3: 0x0000000102e8d6bc libpdalcpp.14.3.0.dylib`pdal::PoissonFilter::run(std::__1::shared_ptr<pdal::PointView>) + 632
    frame #4: 0x00000001030ca788 libpdalcpp.14.3.0.dylib`pdal::StageRunner::run() + 84
    frame #5: 0x0000000103052da0 libpdalcpp.14.3.0.dylib`pdal::Stage::execute(pdal::BasePointTable&, std::__1::set<std::__1::shared_ptr<pdal::PointView>, pdal::PointViewLess, std::__1::allocator<std::__1::shared_ptr<pdal::PointView> > >&) + 1424
    frame #6: 0x0000000103051f74 libpdalcpp.14.3.0.dylib`pdal::Stage::execute(pdal::BasePointTable&) + 1080
    frame #7: 0x000000010302e28c libpdalcpp.14.3.0.dylib`pdal::PipelineManager::execute(pdal::ExecMode) + 188
    frame #8: 0x000000010302e43c libpdalcpp.14.3.0.dylib`pdal::PipelineManager::execute() + 16
abellgithub commented 1 year ago

It looks like the octree needs to be reset. I have to figure out how to do that.