-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Segfault in freeaddrinfo, memory leak in getaddrinfo #16081
Comments
kripken
added a commit
that referenced
this issue
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
I patched |
15 tasks
Great, thanks for verifying @tiran ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In our effort to port CPython to wasm32-emscripten I noticed an unstable test case that crashes sometimes. I was able to reduce the reproducer to
socket.gethostbyname(name)
in a loop. Upon further investigation with MSan I also found a memory leak ingetaddrinfo
that might be related to the issue.Version of emscripten/emsdk:
Failing command line in full:
Full link command and output with
-v
appended:Details
freeaddrinfo crash
WASM dis of freeaddrinfo
If I understand the assembly code correctly, then the crash is caused by deref of
b->ref
on line 14 of github.com/emscripten-core/emscripten/blob/3.1.1/system/lib/libc/musl/src/network/freeaddrinfo.c#L14 . I think there is a mismatch between JSallocaddrinfo
and MUSL freeaddrinfostruct aibuf
.getaddrinfo memory leak
The text was updated successfully, but these errors were encountered: