AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb
[BUG] PCA casts double values that are too large to be represented as an integer.
Open
Nobody has claimed this yet.
bug
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 777
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 34
Description
Environment
Debian Trixie
Describe the bug
PCA is casting double values that cannot be represented as an integer.
When running the unit tests with FPE enabled:
[----------] 1 test from TestPCA
[ RUN ] TestPCA.testPCA
Thread 1 "vdb_test" received signal SIGFPE, Arithmetic exception.
openvdb::v12_1::math::Vec3<int>::Vec3<double> (this=0x7fffffff7354, val=3.4028234156792682e+39)
at /home/bram/src/openvdb/openvdb/openvdb/../openvdb/math/Vec3.h:72
72 this->mm[0] = this->mm[1] = this->mm[2] = static_cast<T>(val);
(gdb) where
#0 openvdb::v12_1::math::Vec3<int>::Vec3<double> (this=0x7fffffff7354, val=3.4028234156792682e+39)
at /home/bram/src/openvdb/openvdb/openvdb/../openvdb/math/Vec3.h:72
#1 0x00005555581758d3 in openvdb::v12_1::points::pca_internal::PcaTransfer<openvdb::v12_1::tree::Tree<openvdb::v12_1::tree::RootNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::points::PointDataLeafNode<openvdb::v12_1::PointIndex<unsigned int, 1u>, 3u>, 4u>, 5u> > > >::range (this=0x7fffedf093c0)
at /home/bram/src/openvdb/openvdb/openvdb/../openvdb/points/impl/PrincipalComponentAnalysisImpl.h:156
#2 0x0000555558173fad in openvdb::v12_1::points::pca_internal::PcaTransfer<openvdb::v12_1::tree::Tree<openvdb::v12_1::tree::RootNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::points::PointDataLeafNode<openvdb::v12_1::PointIndex<unsigned int, 1u>, 3u>, 4u>, 5u> > > >::range (this=0x7fffedf093c0)
at /home/bram/src/openvdb/openvdb/openvdb/../openvdb/points/impl/PrincipalComponentAnalysisImpl.h:155
#3 0x00005555581737e3 in openvdb::v12_1::points::transfer_internal::RasterizePoints<openvdb::v12_1::points::pca_internal::WeightPosSumsTransfer<openvdb::v12_1::tree::Tree<openvdb::v12_1::tree::RootNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::points::PointDataLeafNode<openvdb::v12_1::PointIndex<unsigned int, 1u>, 3u>, 4u>, 5u> > > >, openvdb::v12_1::tree::Tree<openvdb::v12_1::tree::RootNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::points::PointDataLeafNode<openvdb::v12_1::PointIndex<unsigned int, 1u>, 3u>, 4u>, 5u> > >, openvdb::v12_1::points::NullFilter, openvdb::v12_1::util::NullInterrupter>::operator() (
this=0x7fffedf09360, leaf=..., idx=0)
at /home/bram/src/openvdb/openvdb/openvdb/../openvdb/points/PointTransfer.h:545
#4 0x00005555581727ce in openvdb::v12_1::tree::LeafManager<openvdb::v12_1::tree::Tree<openvdb::v12_1::tree::RootNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::points::PointDataLeafNode<openvdb::v12_1::PointIndex<unsigned int, 1u>, 3u>, 4u>, 5u> > > >::LeafTransformer<openvdb::v12_1::points::transfer_internal::RasterizePoints<openvdb::v12_1::points::pca_internal::WeightPosSumsTransfer<openvdb::v12_1::tree::Tree<openvdb::v12_1::tree::RootNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::tree::InternalNode<openvdb::v12_1::points::PointDataLeafNode<openvdb::v12_1::--Type <RET> for more, q to quit, c to continue without paging--q
Quit
To Reproduce
Run TestPCA with FPE enabled
Expected behavior
No FP exception.
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run TestPCA with floating-point exceptions enabled and inspect the cast reported in openvdb/points/impl/PrincipalComponentAnalysisImpl.h, together with the constructor in openvdb/math/Vec3.h. Reproduce the failure using the issue's input and confirm that the test completes without an FP exception for values outside the integer range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100