wildart / FLANN.jl

A Julia wrapper for Fast Library for Approximate Nearest Neighbors (FLANN)
Other
16 stars 14 forks source link

Seqmentation fault when working with closed FLANNIndex #23

Closed slamajakub closed 2 years ago

slamajakub commented 3 years ago

If the FLANNIndex is closed and then used again, the code results in segmentation fault and crash of Julia.

Observed in: OS: Ubuntu 20.04 LTS Julia: 1.5.3

The behavior can be reproduced by

using FLANN
using Distances

X = zeros(3, 2)
t = flann(X, FLANNParameters(), Minkowski(3))
v = zeros(3)

close(t)

knn(t, v, 1)

To prevent the segfault and crash of Julia, it would be beneficial to add some check on the FLANNIndex if it has not been closed prior to passing it to Ccall to catch the misuse and return error instead of segfault.