Socket.dns.getaddrinfo() hangs an app (DEF-3486)

Reproduce step

  1. run Network Link Conditioner (macos app)
  2. set profile “100% loss” in Network Link Conditioner
  3. create a project with one component that contain next code:
function init(self)
	print("before")
	socket.dns.getaddrinfo("amazon.com")
	print("after")
end
  1. Try to build the project.

Application hangs when try to call getaddrinfo with bad connection or problems on a host side. It’s one of the reason of ANRs on Android.

I checked on macOS and Android.

3 Likes

Yes, reproduced here as well. Adding a Jira… DEF-3486

2 Likes

When do you call socket.dns.getaddrinfo()? Is it called behind the scenes since you do a socket.bind()?

This ends up calling getaddrinfo() and from what I can tell it’s not possible to give that method call a timeout. Perhaps some kind of connectivity check should be done before trying to bind the socket?

Yes, I am working on it right now. But I believed that it possible to fix internally for avoiding similar problems in future.

Hmm, yes, maybe it can be solved internally. But we’re talking about the LuaSocket code and the getaddrinfo() C-call which as far as I can tell is completely out of our control.

1 Like

Ok, no problem. I’ll avoid this by checking connectivity before.
It’s an issue in gamesparks sdk, but I don’t know how to report to them, I’ll fix it locally.