This is an archive of the discontinued LLVM Phabricator instance.

[ORC] SimpleRemoteEPCServer: exit gracefully when detecting invalid connection
AbandonedPublic

Authored by sgraenitz on Sep 28 2021, 2:25 AM.

Details

Reviewers
lhames
Summary

In case of invalid connectivity settings, EPC transport's listenLoop() thread may tear down the server. In this case, the main thread won't reach the waitForDisconnect() in the main function and instead exit via ExitOnErr before. The server's ShutdownErr member will still hold an unchecked error, which causes an abnormal shutdown:

SimpleRemoteEPCServer::sendMessage: opc = Setup, seqno = 0, tag-addr = 0x0, arg-buffer = 0x48c bytes
  \--> SimpleRemoteEPC::sendMessage failed
Program aborted due to an unhandled Error:
Bad file descriptor

Call-stack of the main thread:

abort()
llvm::Error::fatalUncheckedError() const
llvm::Error::assertIsChecked()
llvm::Error::~Error()
llvm::orc::SimpleRemoteEPCServer::~SimpleRemoteEPCServer()
...
llvm::Expected<...> llvm::orc::SimpleRemoteEPCServer::Create<...>(...)
main

With this patch applied, the server will shutdown gracefully:

SimpleRemoteEPCServer::sendMessage: opc = Setup, seqno = 0, tag-addr = 0x0, arg-buffer = 0x48c bytes
  \--> SimpleRemoteEPC::sendMessage failed
SimpleRemoteEPCServer: Bad file descriptor
llvm-jitlink-executor: Bad file descriptor

The duplicate error message appears to be originating from the two threads involved.

Diff Detail

Event Timeline

sgraenitz requested review of this revision.Sep 28 2021, 2:25 AM
sgraenitz created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2021, 2:25 AM
sgraenitz abandoned this revision.Jan 5 2022, 1:46 AM

I can't reproduce the original error on mainline anymore. I guess one of the EPC refactors fixed the issue on the way. Thanks