Skip to content

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

3 participants