[PATCH] D98579: [llvm-jitlink] Fix use of getaddrinfo(3) when connecting remote executor via TCP socket

Stefan Gränitz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 13 05:47:15 PST 2021


sgraenitz added a comment.

The patch proposed here is a minimal fix. I am eager to streamline the code and add better error messages in a follow-up commit.



================
Comment at: llvm/tools/llvm-jitlink/llvm-jitlink.cpp:707
   Hints.ai_socktype = SOCK_STREAM;
-  Hints.ai_protocol = PF_INET;
   Hints.ai_flags = AI_NUMERICSERV;
----------------
This caused the getaddrinfo failure below.


================
Comment at: llvm/tools/llvm-jitlink/llvm-jitlink.cpp:722
+    if ((SockFD = socket(AI->ai_family, AI->ai_socktype, AI->ai_protocol)) < 0)
+      continue;
+
----------------
We can pass the obtained AI structs to socket directly, but they might vary from entry to entry.


================
Comment at: llvm/tools/llvm-jitlink/llvm-jitlink.cpp:724
   for (addrinfo *Server = AI; Server; Server = Server->ai_next) {
-    memmove(&Server->ai_addr, &ServAddr.sin_addr.s_addr, Server->ai_addrlen);
-    ConnectRC = connect(SockFD, reinterpret_cast<sockaddr *>(&ServAddr),
----------------
This caused a segfault in any second iteration. Not sure under which conditions the AI output memory is writable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98579/new/

https://reviews.llvm.org/D98579



More information about the llvm-commits mailing list