Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

af.features.Features crashes when its __del__ method is called #268

Open
dan-nf opened this issue Sep 20, 2024 · 1 comment
Open

af.features.Features crashes when its __del__ method is called #268

dan-nf opened this issue Sep 20, 2024 · 1 comment

Comments

@dan-nf
Copy link

dan-nf commented Sep 20, 2024

When using a Features() object, arrayfire crashes silently when calling the object's __del__() method if the object's get_xpos() method has already been deleted (or has fallen out of scope).

Potentially due to a similar root case as mentioned in #169 (or due to the changes made as a result of this in commit a9031fb)

Running on Windows; using arrayfire 3.8.0.

Minimum working example:

import arrayfire as af

def get_feature_locations(features):
    # Get x and y positions of features
    x_pos = features.get_xpos()
    y_pos = features.get_ypos()
    
    # If this is uncommented, the code works as intended
    # return x_pos, y_pos

img = af.randn(d0=500, d1=500)
features, descriptors = af.orb(img, threshold=1, max_features=10, num_levels=1)
feature_locations = get_feature_locations(features)

print("Before delete")
del features
print("After delete")

Which outputs:

Before delete

Uncommenting line 10 (return x_pos, y_pos) outputs:

Before delete
After delete

Thanks!

@dan-nf
Copy link
Author

dan-nf commented Dec 6, 2024

Current workaround is explicitly setting .feat attribute to None and deleting the features object before it falls out of scope; e.g.:

features.feat = None
del features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant