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

Bug: index.hpp leaks memory #138

Closed
2 tasks done
Green-Sky opened this issue Jul 7, 2023 · 8 comments
Closed
2 tasks done

Bug: index.hpp leaks memory #138

Green-Sky opened this issue Jul 7, 2023 · 8 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@Green-Sky
Copy link

Green-Sky commented Jul 7, 2023

Describe the bug

the simple c++ db (index.hpp) leaks. I ran it with asan, and got the following output:

=================================================================
==884330==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1024 byte(s) in 1 object(s) allocated from:
    #0 0x7f8e43669587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x559417f9d685 in unum::usearch::index_gt<unum::usearch::cos_gt<float, float>, unsigned long, unsigned int, std::allocator<char>, std::allocator<char> >::search_to_find_in_base_(unsigned int, unum::usearch::span_gt<float const>, unsigned long, unum::usearch::index_gt<unum::usearch::cos_gt<float, float>, unsigned long, unsigned int, std::allocator<char>, std::allocator<char> >::context_t&) const (/home/green/workspace/clip.cpp/build/bin/image-search+0x46685)
    #2 0x559417fa1883 in unum::usearch::index_gt<unum::usearch::cos_gt<float, float>, unsigned long, unsigned int, std::allocator<char>, std::allocator<char> >::search(unum::usearch::span_gt<float const>, unsigned long, unum::usearch::search_config_t) const (/home/green/workspace/clip.cpp/build/bin/image-search+0x4a883)
    #3 0x559417fa4053 in main (/home/green/workspace/clip.cpp/build/bin/image-search+0x4d053)
    #4 0x7f8e4301d082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 960 byte(s) in 24 object(s) allocated from:
    #0 0x7f8e43669587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x559417f99b1e in unum::usearch::index_gt<unum::usearch::cos_gt<float, float>, unsigned long, unsigned int, std::allocator<char>, std::allocator<char> >::view(char const*) (/home/green/workspace/clip.cpp/build/bin/image-search+0x42b1e)
    #2 0x559417fa3820 in main (/home/green/workspace/clip.cpp/build/bin/image-search+0x4c820)
    #3 0x7f8e4301d082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 512 byte(s) in 1 object(s) allocated from:
    #0 0x7f8e43669587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x559417fa0099 in unum::usearch::index_gt<unum::usearch::cos_gt<float, float>, unsigned long, unsigned int, std::allocator<char>, std::allocator<char> >::search(unum::usearch::span_gt<float const>, unsigned long, unum::usearch::search_config_t) const (/home/green/workspace/clip.cpp/build/bin/image-search+0x49099)
    #2 0x559417fa4053 in main (/home/green/workspace/clip.cpp/build/bin/image-search+0x4d053)
    #3 0x7f8e4301d082 in __libc_start_main ../csu/libc-start.c:308

SUMMARY: AddressSanitizer: 2496 byte(s) leaked in 26 allocation(s).

Steps to reproduce

checkout this pr monatis/clip.cpp#5 (or main if merged)

Expected behavior

no leakage :)

USearch version

v0.19.3

Operating System

ubuntu 20.04

Hardware architecture

x86

Which interface are you using?

C++ implementation

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Green-Sky Green-Sky added bug Something isn't working invalid This doesn't seem right labels Jul 7, 2023
@Green-Sky
Copy link
Author

why do you default bugs with the invalid tag?

@ashvardanian
Copy link
Contributor

@Green-Sky thank you for opening the issue! We pre-set the invalid tag, cause its often easier to disable the ones that you don't need, rather than search for the tags that apply. As for the issue, @DarvinHarutyunyan and @davvard can you please check this?

@ashvardanian
Copy link
Contributor

@gurgenyegoryan Can you please enable ASAN in our CI unit tests?

@gurgenyegoryan
Copy link
Contributor

@ashvardanian Yes, no problem, I'll add it now.

@davvard
Copy link
Contributor

davvard commented Jul 10, 2023

The issue has been detected, we are fixing it

@ashvardanian
Copy link
Contributor

@Green-Sky please let us know if v0.20 fixes the leaks 🤗

@Green-Sky
Copy link
Author

can confirm, memory leak is fixed :)

also, you never removed the invalid tag :P

Green-Sky added a commit to Green-Sky/clip.cpp that referenced this issue Jul 10, 2023
@ashvardanian
Copy link
Contributor

Perfect, @Green-Sky!

Our work interests seemingly intersect, and we would happily explore more collaboration opportunities over time.
Some of the other projects that immediately pop into mind are:

But there is even more in corporate and personal repos of our team-mates 🤗

monatis pushed a commit to monatis/clip.cpp that referenced this issue Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants