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 LibC.accept segfault #4788
Fix LibC.accept segfault #4788
Conversation
The way the kernel has to know how big
So if I'm not sure about the portability of passing Lastly, any link to a report of the issue would be great. If we can get any idea of the portability of the fix, I'm |
@matiasgarciaisaia I know that providing a random number as the length is wrong, but my point is that the kernel has no reason to write more than As for the portability: it's in posix. Freebsd and openbsd man pages say exactly the same thing:
|
Segfaulting is bad thing, but should be reviewed anywhere else. It's OK to provide "Need no data" to LGTM. |
Long shot here: is there any chance you're sometimes getting an IPv6 connection? The "default" Since the Please do share here a link to any specific instance of the bug, anyways. |
@matiasgarciaisaia the loopback interface is ipv6, that'd do it. The spec looks up localhost (it runs a test HTTP server) which is |
Neither
client_addr
orclient_addrlen
are used in the following function, butout
params were used. The man page says these two arguments should beNULL
if they're unused. Once I made this change, compilingspec/std/http/client/client_spec.cr
in release mode stopped segfaulting.I'm not entirely sure why this segfaulted in the first place, but it's likely to do with how
client_addrlen
is used by the kernel as the length of thesockaddr*
. I thinkout client_addrlen
is sending a random number on the top of the stack to the kernel. @oprypin raised the point that this shouldn't matter, since we allocatedsizeof(struct sockaddr)
forclient_addr
, and surely the kernel wouldn't write more than that? Who knows, this commit fixes it at least.