[thread] Ingore errors saving state after user-suspend

As the comment I added says, sometimes a process is killed while
user-suspended (e.g. when LLDB sends the kill signal while debugging).
In such cases, trying to save the state back to the process will fail
(since it no longer exists). We can safely ignore such errors, but let's
also log a warning just-in-case.
This commit is contained in:
Ariel Abreu 2023-03-13 13:31:32 -04:00
parent 697fa6e643
commit 8e57a9213a
No known key found for this signature in database
GPG Key ID: 5B88AAAF4280706F

View File

@ -1407,7 +1407,13 @@ DarlingServer::Thread::RunState DarlingServer::Thread::getRunState() const {
void DarlingServer::Thread::waitWhileUserSuspended(uintptr_t threadStateAddress, uintptr_t floatStateAddress) {
loadStateFromUser(threadStateAddress, floatStateAddress);
dtape_thread_wait_while_user_suspended(_dtapeThread);
saveStateToUser(threadStateAddress, floatStateAddress);
try {
saveStateToUser(threadStateAddress, floatStateAddress);
} catch (std::system_error e) {
// if we fail to save the state back to the process, that likely means the process died or was killed while waiting.
// it's nothing to worry about. just log it and move on.
threadLog.warning() << *this << ": failed to save state back to user in waitWhileUserSuspended: " << e.code() << " (" << e.what() << ")" << threadLog.endLog;
}
};
void DarlingServer::Thread::sendSignal(int signal) const {