Skip to content
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

SDLNet_WaitUntilResolved is broken when using timeouts #96

Open
JoelLinn opened this issue May 3, 2024 · 0 comments
Open

SDLNet_WaitUntilResolved is broken when using timeouts #96

JoelLinn opened this issue May 3, 2024 · 0 comments
Assignees

Comments

@JoelLinn
Copy link

JoelLinn commented May 3, 2024

SDL_net 78dc786
SDL d95f5bad2459608816cbf24f14dcab618a4a9ab7 prerelease-3.1.2

Hi,

when setting a timeout, SDLNet_WaitUntilResolved has broken behaviour.
This can be reproduced using one of the examples:

diff --git a/examples/resolve-hostnames.c b/examples/resolve-hostnames.c
index ac28e7b..0efae0d 100644
--- a/examples/resolve-hostnames.c
+++ b/examples/resolve-hostnames.c
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
     }
 
     for (int i = 1; i < argc; i++) {
-        SDLNet_WaitUntilResolved(addrs[i], -1);
+        SDLNet_WaitUntilResolved(addrs[i], 1000);
 
         if (SDLNet_GetAddressStatus(addrs[i]) == -1) {
             SDL_Log("%s: [FAILED TO RESOLVE: %s]", argv[i], SDL_GetError());
> ./resolve-hostnames 8.8.8.8

Issues:

  • The hostname(s) will not resolve: INFO: 8.8.8.8: (null) but the return code indicates success (except when adding SDL_Delay(1000); before the call to SDLNet_WaitUntilResolved, indicating a race)
  • The application will hang on SDLNet_Quit(), waiting for the resolve threads:
(gdb) bt 10
#0  0x00007ffff7aa5ebe in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff7aab0e3 in ?? () from /usr/lib/libc.so.6
#2  0x00007ffff7ea2019 in SDL_SYS_WaitThread () from /home/[...]/SDL/cmake-install/lib/libSDL3.so.0
#3  0x00007ffff7d0ba98 in SDL_WaitThread_REAL () from /home/[...]/SDL/cmake-install/lib/libSDL3.so.0
#4  0x00007ffff7c6594c in SDL_WaitThread () from /home/[...]/SDL/cmake-install/lib/libSDL3.so.0
#5  0x00007ffff7fb90e1 in SDLNet_Quit () at /home/[...]/SDL_net/src/SDL_net.c:442
#6  0x000055555555537b in main (argc=2, argv=0x7fffffffe428) at /home/[...]/SDL_net/examples/resolve-hostnames.c:39
@icculus icculus self-assigned this May 3, 2024
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

No branches or pull requests

2 participants