Hang on waitpid method when closing helper process in MacOS

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Hang on waitpid method when closing helper process in MacOS

Postby Andycef » Wed Sep 23, 2020 4:37 am

I encountered waitpid hang problem in our cef app on MacOS platform. The reproduce steps are as follows. I checked system tool, the related helper process (process "child" in code "waitpid(child, NULL, 0)") doesn't appear in Activity Monitor. However "const pid_t result = HANDLE_EINTR(waitpid(child, NULL, 0));" blocks this run worker thread and leads the subsequent cef browser process creation logic failure.

It seems that native subprocess creation in step 2) interrupts waitpid on dying helper process. Is it a cef bug in MacOS platform? Does anyone have a solution or workaround for it?

Reproduce steps:
1. open a window with cef webview, helper process is launched successfully.
2. Implement subprocess fork logic (e.g. vfork() and execlp()) in my native code.
2. close the window, helper process shut down thread is blocked on waitpid in BlockingReap method.


base/process/kill_mac.cc:26
// Reap |child| process. This call blocks until completion.
void BlockingReap(pid_t child) {
const pid_t result = HANDLE_EINTR(waitpid(child, NULL, 0));
if (result == -1) {
DPLOG(ERROR) << "waitpid(" << child << ", NULL, 0)";
}
}


#0 0x00007fff648a4926 in __wait4 ()
#1 0x000000010790befb in base::(anonymous namespace)::BlockingReap(int) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/process/kill_mac.cc:26
#2 0x000000010790be43 in base::(anonymous namespace)::WaitForChildToDie(int, int) [inlined] at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/process/kill_mac.cc:163
#3 0x000000010790b9b9 in base::EnsureProcessTerminated(base::Process) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/process/kill_mac.cc:170
#4 0x00000001063b2fcf in content::internal::ChildProcessLauncherHelper::ForceNormalProcessTerminationSync(content::internal::ChildProcessLauncherHelper::Process) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/content/browser/child_process_launcher_helper_mac.cc:257
#5 0x00000001063b2375 in void base::internal::FunctorTraits<void (*)(content::internal::ChildProcessLauncherHelper::Process), void>::Invoke<void (*)(content::internal::ChildProcessLauncherHelper::Process), content::internal::ChildProcessLauncherHelper::Process>(void (*&&)(content::internal::ChildProcessLauncherHelper::Process), content::internal::ChildProcessLauncherHelper::Process&&) [inlined] at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/bind_internal.h:399
#6 0x00000001063b2367 in void base::internal::InvokeHelper<false, void>::MakeItSo<void (*)(content::internal::ChildProcessLauncherHelper::Process), content::internal::ChildProcessLauncherHelper::Process>(void (*&&)(content::internal::ChildProcessLauncherHelper::Process), content::internal::ChildProcessLauncherHelper::Process&&) [inlined] at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/bind_internal.h:599
#7 0x00000001063b2367 in void base::internal::Invoker<base::internal::BindState<void (*)(content::internal::ChildProcessLauncherHelper::Process), content::internal::ChildProcessLauncherHelper::Process>, void ()>::RunImpl<void (*)(content::internal::ChildProcessLauncherHelper::Process), std::__1::tuple<content::internal::ChildProcessLauncherHelper::Process>, 0ul>(void (*&&)(content::internal::ChildProcessLauncherHelper::Process), std::__1::tuple<content::internal::ChildProcessLauncherHelper::Process>&&, std::__1::integer_sequence<unsigned long, 0ul>) [inlined] at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/bind_internal.h:672
#8 0x00000001063b2367 in base::internal::Invoker<base::internal::BindState<void (*)(content::internal::ChildProcessLauncherHelper::Process), content::internal::ChildProcessLauncherHelper::Process>, void ()>::RunOnce(base::internal::BindStateBase*) at /Users/spotify-buildagent/buildAgent/work/CEF3_git/chromium/src/base/bind_internal.h:641
#9 0x0000000107936813 in base::OnceCallback<void ()>::Run() && [inlined] at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/callback.h:97
#10 0x00000001079367b9 in base::TaskAnnotator::RunTask(char const*, base::PendingTask*) at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/common/task_annotator.cc:114
#11 0x000000010796bf02 in base::internal::TaskTracker::RunBlockShutdown(base::internal::Task*) at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/task_tracker.cc:715
#12 0x000000010796baba in base::internal::TaskTracker::RunTaskWithShutdownBehavior(base::TaskShutdownBehavior, base::internal::Task*) [inlined] at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/task_tracker.cc:730
#13 0x000000010796bab2 in base::internal::TaskTracker::RunOrSkipTask(base::internal::Task, base::internal::Sequence*, base::TaskTraits const&, bool) at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/task_tracker.cc:563
#14 0x00000001079b918e in base::internal::TaskTrackerPosix::RunOrSkipTask(base::internal::Task, base::internal::Sequence*, base::TaskTraits const&, bool) at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/task_tracker_posix.cc:24
#15 0x000000010796afdc in base::internal::TaskTracker::RunAndPopNextTask(scoped_refptr<base::internal::Sequence>) at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/task_tracker.cc:427
#16 0x0000000107960a43 in base::internal::SchedulerWorker::RunWorker() at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/scheduler_worker.cc:340
#17 0x0000000107960814 in base::internal::SchedulerWorker::RunDedicatedWorker() at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/task/thread_pool/scheduler_worker.cc:257
#18 0x00000001079b963f in base::(anonymous namespace)::ThreadFunc(void*) at /Users/spotify-buildagent/buildAgent/work/215ce731d4621561/CEF3_git/chromium/src/base/threading/platform_thread_posix.cc:81
Andycef
Newbie
 
Posts: 2
Joined: Mon Aug 24, 2020 5:24 am

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 53 guests