зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1741152 - Add diagnostic warnings to process launch codepaths, r=ipc-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D131419
This commit is contained in:
Родитель
4f3833aa2f
Коммит
ab32545d5a
|
@ -1081,7 +1081,7 @@ ContentParent::GetNewOrUsedLaunchingBrowserProcess(
|
|||
PromiseFlatCString(aRemoteType).get()));
|
||||
|
||||
contentParent = new ContentParent(aRemoteType);
|
||||
if (!contentParent->BeginSubprocessLaunch(aPriority)) {
|
||||
if (NS_WARN_IF(!contentParent->BeginSubprocessLaunch(aPriority))) {
|
||||
// Launch aborted because of shutdown. Bailout.
|
||||
contentParent->LaunchSubprocessReject();
|
||||
return nullptr;
|
||||
|
@ -2503,7 +2503,8 @@ bool ContentParent::BeginSubprocessLaunch(ProcessPriority aPriority) {
|
|||
AUTO_PROFILER_LABEL("ContentParent::LaunchSubprocess", OTHER);
|
||||
|
||||
if (!ContentProcessManager::GetSingleton()) {
|
||||
// Shutdown has begun, we shouldn't spawn any more child processes.
|
||||
NS_WARNING(
|
||||
"Shutdown has begun, we shouldn't spawn any more child processes");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2519,6 +2520,7 @@ bool ContentParent::BeginSubprocessLaunch(ProcessPriority aPriority) {
|
|||
// `LaunchSubprocessReject`/`LaunchSubprocessResolve`.
|
||||
mPrefSerializer = MakeUnique<mozilla::ipc::SharedPreferenceSerializer>();
|
||||
if (!mPrefSerializer->SerializeToSharedMemory()) {
|
||||
NS_WARNING("SharedPreferenceSerializer::SerializeToSharedMemory failed");
|
||||
MarkAsDead();
|
||||
return false;
|
||||
}
|
||||
|
@ -2628,6 +2630,7 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync,
|
|||
// marked as DEAD, fail the process launch, and immediately begin tearing down
|
||||
// the content process.
|
||||
if (IsDead()) {
|
||||
NS_WARNING("immediately shutting-down already-dead process");
|
||||
ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -244,6 +244,7 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
|||
EnvironmentArray envp = BuildEnvironmentArray(options.env_map);
|
||||
mozilla::ipc::FileDescriptorShuffle shuffle;
|
||||
if (!shuffle.Init(options.fds_to_remap)) {
|
||||
DLOG(WARNING) << "FileDescriptorShuffle::Init failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -269,7 +270,10 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
|||
pid_t pid = fork();
|
||||
#endif
|
||||
|
||||
if (pid < 0) return false;
|
||||
if (pid < 0) {
|
||||
DLOG(WARNING) << "fork() failed: " << strerror(errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
// In the child:
|
||||
|
|
|
@ -40,6 +40,7 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
|
||||
posix_spawn_file_actions_t file_actions;
|
||||
if (posix_spawn_file_actions_init(&file_actions) != 0) {
|
||||
DLOG(WARNING) << "posix_spawn_file_actions_init failed";
|
||||
return false;
|
||||
}
|
||||
auto file_actions_guard =
|
||||
|
@ -48,6 +49,7 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
// Turn fds_to_remap array into a set of dup2 calls.
|
||||
mozilla::ipc::FileDescriptorShuffle shuffle;
|
||||
if (!shuffle.Init(options.fds_to_remap)) {
|
||||
DLOG(WARNING) << "FileDescriptorShuffle::Init failed";
|
||||
return false;
|
||||
}
|
||||
for (const auto& fd_map : shuffle.Dup2Sequence()) {
|
||||
|
@ -55,6 +57,7 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
int dest_fd = fd_map.second;
|
||||
|
||||
if (posix_spawn_file_actions_adddup2(&file_actions, src_fd, dest_fd) != 0) {
|
||||
DLOG(WARNING) << "posix_spawn_file_actions_adddup2 failed";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +65,7 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
// Initialize spawn attributes.
|
||||
posix_spawnattr_t spawnattr;
|
||||
if (posix_spawnattr_init(&spawnattr) != 0) {
|
||||
DLOG(WARNING) << "posix_spawnattr_init failed";
|
||||
return false;
|
||||
}
|
||||
auto spawnattr_guard =
|
||||
|
@ -75,6 +79,7 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
int rv;
|
||||
rv = posix_spawnattr_setbinpref_np(&spawnattr, count, &cpu_pref, &ocount);
|
||||
if ((rv != 0) || (ocount != count)) {
|
||||
DLOG(WARNING) << "posix_spawnattr_setbinpref_np failed";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -84,12 +89,14 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
// that aren't named in `file_actions`. (This is an Apple-specific
|
||||
// extension to posix_spawn.)
|
||||
if (posix_spawnattr_setflags(&spawnattr, POSIX_SPAWN_CLOEXEC_DEFAULT) != 0) {
|
||||
DLOG(WARNING) << "posix_spawnattr_setflags failed";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Exempt std{in,out,err} from being closed by POSIX_SPAWN_CLOEXEC_DEFAULT.
|
||||
for (int fd = 0; fd <= STDERR_FILENO; ++fd) {
|
||||
if (posix_spawn_file_actions_addinherit_np(&file_actions, fd) != 0) {
|
||||
DLOG(WARNING) << "posix_spawn_file_actions_addinherit_np failed";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +107,7 @@ bool LaunchApp(const std::vector<std::string>& argv, const LaunchOptions& option
|
|||
|
||||
bool process_handle_valid = pid > 0;
|
||||
if (!spawn_succeeded || !process_handle_valid) {
|
||||
DLOG(WARNING) << "posix_spawnp failed";
|
||||
retval = false;
|
||||
} else {
|
||||
gProcessLog.print("==> process %d launched child process %d\n", GetCurrentProcId(), pid);
|
||||
|
|
|
@ -367,7 +367,10 @@ bool LaunchApp(const std::wstring& cmdline, const LaunchOptions& options,
|
|||
NULL, const_cast<wchar_t*>(cmdline.c_str()), NULL, NULL, bInheritHandles,
|
||||
dwCreationFlags, new_env_ptr, NULL, &startup_info, &process_info);
|
||||
if (lpAttributeList) FreeThreadAttributeList(lpAttributeList);
|
||||
if (!createdOK) return false;
|
||||
if (!createdOK) {
|
||||
DLOG(WARNING) << "CreateProcess Failed: " << GetLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
gProcessLog.print("==> process %d launched child process %d (%S)\n",
|
||||
GetCurrentProcId(), process_info.dwProcessId,
|
||||
|
|
|
@ -279,7 +279,7 @@ class PosixProcessLauncher : public BaseProcessLauncher {
|
|||
int origSrcFd;
|
||||
aChannel->GetClientFileDescriptorMapping(&origSrcFd, &mChannelDstFd);
|
||||
mChannelSrcFd.reset(dup(origSrcFd));
|
||||
if (!mChannelSrcFd) {
|
||||
if (NS_WARN_IF(!mChannelSrcFd)) {
|
||||
return false;
|
||||
}
|
||||
aChannel->CloseClientFileDescriptor();
|
||||
|
@ -1206,8 +1206,8 @@ bool PosixProcessLauncher::DoSetup() {
|
|||
if (!CrashReporter::IsDummy()) {
|
||||
# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS)
|
||||
int childCrashFd, childCrashRemapFd;
|
||||
if (!CrashReporter::CreateNotificationPipeForChild(&childCrashFd,
|
||||
&childCrashRemapFd)) {
|
||||
if (NS_WARN_IF(!CrashReporter::CreateNotificationPipeForChild(
|
||||
&childCrashFd, &childCrashRemapFd))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1431,7 +1431,8 @@ bool WindowsProcessLauncher::DoSetup() {
|
|||
// so use sandbox level USER_RESTRICTED instead of USER_LOCKDOWN.
|
||||
auto level =
|
||||
isWidevine ? SandboxBroker::Restricted : SandboxBroker::LockDown;
|
||||
if (!mResults.mSandboxBroker->SetSecurityLevelForGMPlugin(level)) {
|
||||
if (NS_WARN_IF(
|
||||
!mResults.mSandboxBroker->SetSecurityLevelForGMPlugin(level))) {
|
||||
return false;
|
||||
}
|
||||
mUseSandbox = true;
|
||||
|
@ -1454,7 +1455,8 @@ bool WindowsProcessLauncher::DoSetup() {
|
|||
break;
|
||||
case GeckoProcessType_RDD:
|
||||
if (!PR_GetEnv("MOZ_DISABLE_RDD_SANDBOX")) {
|
||||
if (!mResults.mSandboxBroker->SetSecurityLevelForRDDProcess()) {
|
||||
if (NS_WARN_IF(
|
||||
!mResults.mSandboxBroker->SetSecurityLevelForRDDProcess())) {
|
||||
return false;
|
||||
}
|
||||
mUseSandbox = true;
|
||||
|
@ -1462,7 +1464,8 @@ bool WindowsProcessLauncher::DoSetup() {
|
|||
break;
|
||||
case GeckoProcessType_Socket:
|
||||
if (!PR_GetEnv("MOZ_DISABLE_SOCKET_PROCESS_SANDBOX")) {
|
||||
if (!mResults.mSandboxBroker->SetSecurityLevelForSocketProcess()) {
|
||||
if (NS_WARN_IF(
|
||||
!mResults.mSandboxBroker->SetSecurityLevelForSocketProcess())) {
|
||||
return false;
|
||||
}
|
||||
mUseSandbox = true;
|
||||
|
@ -1690,7 +1693,7 @@ RefPtr<ProcessHandlePromise> AndroidProcessLauncher::LaunchAndroidService(
|
|||
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
|
||||
bool GeckoChildProcessHost::AppendMacSandboxParams(StringVector& aArgs) {
|
||||
MacSandboxInfo info;
|
||||
if (!FillMacSandboxInfo(info)) {
|
||||
if (NS_WARN_IF(!FillMacSandboxInfo(info))) {
|
||||
return false;
|
||||
}
|
||||
info.AppendAsParams(aArgs);
|
||||
|
@ -1779,7 +1782,7 @@ RefPtr<ProcessLaunchPromise> BaseProcessLauncher::Launch(
|
|||
// great.
|
||||
bool failed = false;
|
||||
aHost->InitializeChannel([&](IPC::Channel* channel) {
|
||||
if (!channel || !SetChannel(channel)) {
|
||||
if (NS_WARN_IF(!channel || !SetChannel(channel))) {
|
||||
failed = true;
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче