Skip to content

Fix freeaddrinfo(), which did not match allocation in JS. #16085

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

Merged
merged 1 commit into from
Jan 21, 2022
Merged

Conversation

kripken
Copy link
Member

@kripken kripken commented Jan 21, 2022

It is risky to allocate in JS and free in C, when given matching allocate/free
pairs like getaddrinfo/freeaddrinfo, and it looks like we had things wrong
here. That is, the existing musl code did not match how we use that
structure. The worst part is that musl appears to assume the struct is
identical/can alias some other struct, and that led to memory corruption.

Not sure if we can test this reliably as the issue is corruption.

Fixes #16081

@sbc100
Copy link
Collaborator

sbc100 commented Jan 21, 2022

Would it make more sense to add freeaddrinfo to JS (to match getaddrinfo?) and skip compiling this file?

Either way lgtm.

@kripken
Copy link
Member Author

kripken commented Jan 21, 2022

I considered moving it to JS, yeah - would be more symmetrical. But that's the wrong direction 😉 Ideally we should convert getaddrinfo into C, but that is quite a lot of work, probably...

@sbc100
Copy link
Collaborator

sbc100 commented Jan 21, 2022

sgtm

@kripken kripken merged commit 89eef69 into main Jan 21, 2022
@kripken kripken deleted the freeaddrinfo branch January 21, 2022 22:24
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.

Segfault in freeaddrinfo, memory leak in getaddrinfo
2 participants