This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by sgraenitz on Mar 13 2021, 5:35 AM.

Details

Summary

Since llvm-jitlink moved from gethostbyname to getaddrinfo in D95477, it seems to no longer connect to llvm-jitlink-executor via TCP. I can reproduce this behavior on both, Debian 10 and macOS 10.15.7:

> llvm-jitlink-executor listen=localhost:10819
--
> llvm-jitlink --oop-executor-connect=localhost:10819 /path/to/obj.o
Failed to resolve localhost:10819

Diff Detail

Event Timeline

sgraenitz requested review of this revision.Mar 13 2021, 5:35 AM
sgraenitz created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 13 2021, 5:35 AM

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.

llvm/tools/llvm-jitlink/llvm-jitlink.cpp
707

This caused the getaddrinfo failure below.

722

We can pass the obtained AI structs to socket directly, but they might vary from entry to entry.

724

This caused a segfault in any second iteration. Not sure under which conditions the AI output memory is writable.

Unfortunately, we seem to have no test coverage for this code. My last take was that LIT doesn't exactly make it easy to run client and server concurrently. Is that still the case or could we do it somehow differently?
I had to take a detailed look into this code now anyway, so I could just as well add a test case.

rzurob accepted this revision.Mar 19 2021, 10:20 AM

LGTM

This revision is now accepted and ready to land.Mar 19 2021, 10:20 AM
This revision was landed with ongoing or failed builds.Mar 22 2021, 3:21 AM
This revision was automatically updated to reflect the committed changes.