Skip to content

Commit 662d385

Browse files
authored
[lldb/telemetry] Report exit status only once (#134078)
SetExitStatus can be called the second time when we reap the debug server process. This shouldn't be interesting as at that point, we've already told everyone that the process has exited. I believe/hope this will also help with sporadic shutdown crashes that have cropped up recently. They happen because the debug server is monitored from a detached thread, so this code can be called after main returns (and starts destroying everything). This isn't a real fix for that though, as the situation can still happen (it's just that it usually happens after the exit status has already been set). I think the real fix for that is to make sure these threads terminate before we start shutting everything down.
1 parent 0949043 commit 662d385

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lldb/source/Target/Process.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,20 @@ const char *Process::GetExitDescription() {
10671067
bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
10681068
// Use a mutex to protect setting the exit status.
10691069
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
1070+
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
1071+
LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
1072+
GetPluginName(), status, exit_string);
1073+
1074+
// We were already in the exited state
1075+
if (m_private_state.GetValue() == eStateExited) {
1076+
LLDB_LOG(
1077+
log,
1078+
"(plugin = {0}) ignoring exit status because state was already set "
1079+
"to eStateExited",
1080+
GetPluginName());
1081+
return false;
1082+
}
1083+
10701084
telemetry::ScopedDispatcher<telemetry::ProcessExitInfo> helper;
10711085

10721086
UUID module_uuid;
@@ -1089,20 +1103,6 @@ bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
10891103
info->pid = m_pid;
10901104
});
10911105

1092-
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
1093-
LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",
1094-
GetPluginName(), status, exit_string);
1095-
1096-
// We were already in the exited state
1097-
if (m_private_state.GetValue() == eStateExited) {
1098-
LLDB_LOG(
1099-
log,
1100-
"(plugin = {0}) ignoring exit status because state was already set "
1101-
"to eStateExited",
1102-
GetPluginName());
1103-
return false;
1104-
}
1105-
11061106
m_exit_status = status;
11071107
if (!exit_string.empty())
11081108
m_exit_string = exit_string.str();

0 commit comments

Comments
 (0)