Instacrash with `fluid.knnclassifier~` when `predictpoint`-ing after `clear`-ing
rconstanzo opened this issue · 6 comments
This was reported to me by an SP-Tools user, but in narrowing things down, I can 100% reproduce it, and it happens with purely with FluCoMa objects.
Basically you fit
a dataset/labelset in fluid.knnclassifier~
then after clear
-ing it, if you send a predictpoint
message, Max instantly crashes. This is 100% reproduceable.
I'm on Max 8.5.2 with FluComa version 1.0.5+sha.9db1bdd.core.sha.001df55a
I'm attaching a crash report from myself, and one from another user, but both have the same/similar spicy bits:
0 org.flucoma.fluid.libmanipulation 0x0000000125f9d561 fluid::algorithm::KNNClassifier::predict(fluid::algorithm::KDTree const&, fluid::FluidTensorView<double, 1ul>, fluid::FluidDataSet<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, 1l> const&, long, bool, fluid::FallbackAllocator&) const + 321
I didn't ask him, but I imagine he's on 1.0, or 1.01 or whatever as the 1.05 is pretty hot off the presses, so it's possible this bug has been there for a bit?
I can confirm - I think I know why but I'll need to check with @weefuzzy - the problem is in the 'clearing' of the underlying kdtree - I think we should be more violent and also update mDims = 0
and mNPoints = {0}
as per loading state but maybe he will want to do something more principled and deallocate memory and stuff...
You're quite right – although it's not a question of violence, just of leaving the object in a consistent state. I'm a bit alarmed that mDims
isn't actually properly initialized in any case.
Because the tree is built using std::shared_ptr
(which isn't great), all the deallocation has already happened.
i'll do a pr and send your way for review, including initialising size to 0
Already coded, confirmed fixed and about to commit 😄
This should be fixed in next nightly. Do re-open if not.
and all of that while I was dealing with Lufthansa on hold... thanks!