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

Fix memory leaks #32

Closed

Conversation

lucic71
Copy link
Contributor

@lucic71 lucic71 commented May 7, 2024

No description provided.

Copy link
Contributor

@hartwork hartwork left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are interesting findings 👍 For at least half of this, I'm not sure yet whether this is already the complete picture and the fix needed. This grep result puzzles me:

# git rev-parse HEAD ; git --no-pager grep hashstr_buf_size
4d37fd3549a199786796bd9bffd907523f5aea4d
src/hash.c:size_t hashstr_buf_size;
src/hash.h:extern size_t hashstr_buf_size;
src/hash.h:    size_t hashstr_buf_size;
src/verify.c:            cmp = memcmp(ihash, vhash, hashl->hash->hashstr_buf_size);
src/verify.c:        cmp = memcmp(ihash, vhash, hashl->hash->hashstr_buf_size);
src/verify.c:    i_hashstr_buf = malloc(hashstr_buf_size);
src/verify.c:    v_hashstr_buf = malloc(hashstr_buf_size);
src/verify.c:        cmp = memcmp(ihash, vhash, ihashlist->hash->hashstr_buf_size);

When is hashstr_buf_size content — both globally and the struct member — ever written to?

CC @davidpolverari

@lucic71
Copy link
Contributor Author

lucic71 commented May 7, 2024

hashstr_buf also seems to be read in a lot of places but never written.

Edit: hastype_t.final, which usee hashstr_buf, isn't written anywhere, as well.

@davidpolverari
Copy link
Collaborator

Hmm. For this one, I will leave it for the time when I'm able to run it through valgrind and gdb (probably over the weekend) and see whether data is ever written on those locations.

@hartwork
Copy link
Contributor

hartwork commented May 9, 2024

@davidpolverari unfixed compile warnings in the CI logs seem to confirm. This is for latest master:

2024-05-08T02:42:50.0167219Z verify.c:147:11: warning: variable 'i_hashstr_buf' set but not used [-Wunused-but-set-variable]
2024-05-08T02:42:50.0167811Z   147 |     char *i_hashstr_buf;
2024-05-08T02:42:50.0168195Z       |           ^
2024-05-08T02:42:50.0168870Z verify.c:148:11: warning: variable 'v_hashstr_buf' set but not used [-Wunused-but-set-variable]
2024-05-08T02:42:50.0169458Z   148 |     char *v_hashstr_buf;
2024-05-08T02:42:50.0169840Z       |           ^

@davidpolverari
Copy link
Collaborator

Merged on master. Closing manually, as I had to rebase before merging. Thanks for the help!

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

Successfully merging this pull request may close these issues.

None yet

3 participants