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 minor memleak in Go bindings #241

Merged
merged 3 commits into from Mar 24, 2023
Merged

Fix minor memleak in Go bindings #241

merged 3 commits into from Mar 24, 2023

Conversation

jtraglia
Copy link
Member

@jtraglia jtraglia commented Mar 23, 2023

The allocated C strings that were being passed to fopen were never being freed. I thought these were casts.

  • Call defer free for the two strings right after allocating them.
  • Change mode from "rb" to "r" because the trusted setup shouldn't be binary.

@asn-d6
Copy link
Contributor

asn-d6 commented Mar 24, 2023

Nice find. Maybe we suffer from a similar file descriptor leak in the nodejs bindings: https://github.com/ethereum/c-kzg-4844/blob/main/bindings/node.js/src/kzg.cxx#L142

Should we fix it as part of this PR or open a new one?

@jtraglia
Copy link
Member Author

@asn-d6 yes, I believe that may also be a problem. Doesn't look like the file is explicitly closed either.

I think we should fix Node.js in a different PR and merge this one as is.

@asn-d6
Copy link
Contributor

asn-d6 commented Mar 24, 2023

Merged this one. Opened #246 for the nodejs issue.

@asn-d6 asn-d6 merged commit c448e9b into ethereum:main Mar 24, 2023
18 checks passed
@jtraglia jtraglia deleted the fix-go-memleak branch March 24, 2023 13:59
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

2 participants