Chrome Zygote solves major Shared Library issue

Sysadmins have a love-hate relationship with shared libraries. They save space, they make upgrades easier, and so on.  However, they also cause many problems.  Sometimes they cause versioning problems (Windows DLLs), security problems, and (at least when they were new) performance problems.  I won't go into detail, just mention them on a technical email list and you'll get an earful.

Here's one example that hits me a lot. On my Linux box, if I run an update of Firefox, my current Firefox browser keeps running. However, the next time it needs to load a shared library, it is now loading the upgraded version which is incompatible and my Firefox goes bonkers and/or crashes. On the Mac and Windows this doesn't happen because the installer waits for you to close any Firefox instances before continuing.

Google Chrome browser does its updates in the background while you use it. The user doesn't have to wait for any painful upgrade notification. Instead, the next time they run Chrome they are simply told that they are now running the newest release. I call this a "parent-friendly" feature because the last time I visited my mom much of her software had been asking to be upgraded for months.  I wish it could have just upgraded itself and kept my mom's computer more secure. ACM has an article by the Chrome authors about why automatic upgrades are a key security issue. (with graphs of security attacks vs. upgrade statistics)

However, if Google Chrome upgrades itself in place, how does it keep running without crashing? Well, it turns out, they use a technique called the LinuxZygote.  The libraries they need are loaded at startup into a process which then fork()s any time they need, for example, a renderer. The Zygote pattern is usually done for systems that have a slow startup time. However, they claim that in their testing there was no performance improvement. They do this to make the system more stable.

Read the (brief) article for more info: LinuxZygote


Posted by Tom Limoncelli in Technical Tips

No TrackBacks

TrackBack URL: http://everythingsysadmin.com/cgi-bin/mt-tb.cgi/1030

3 Comments | Leave a comment

Hi Tom,
I'm writing a blog post about Aprigo's NINJA's automatic updates, I'm referring back to your blog post, but the link "ACM has an article by the Chrome authors about why automatic upgrades are a key security issue." doesn't work for me...

Tsahy: The link works for me. Please try again.

Dear Sir,
Dear Sir,
I have a issue about chrome processes when close the browser, there is a issue about zygote process:
When I close the chrome 39 browser, then I use "ps -aux | grep chrome" on the shell, I found there is still final process in the list was running with flag "--type=zygote". Now , I will attach the info below
my platform is cpu mips64el, os is centos6.4, both are 64 bits

1) use "ps -aux | grep chrome" on the shell when the chrome39 browser is open
[zqiang@localhost ~]$ ps -aux | grep chrome
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
zqiang 15839 0.0 0.0 102160 1392 pts/0 S+ 16:53 0:00 grep chrome
zqiang 18839 0.0 0.1 103168 2208 ? S 16:51 0:00 sh chrome39.sh
zqiang 18861 20.4 6.4 2794016 125024 ? Sl 16:51 0:18 /opt/chrome39/chrome --ignore-gpu-blacklist
zqiang 23409 0.0 0.0 2864 1008 ? S 16:52 0:00 /opt/chrome39/chrome-sandbox /opt/chrome39/chrome --type=zygote
zqiang 23415 13.5 2.6 363776 50832 ? S 16:52 0:10 /opt/chrome39/chrome --type=zygote
zqiang 26796 0.0 0.7 363776 14192 ? S 16:52 0:00 /opt/chrome39/chrome --type=zygote
zqiang 27983 22.1 4.1 660864 80176 ? Sl 16:52 0:13 /opt/chrome39/chrome --type=gpu-process --channel=18861.0.611353833 --disable-breakpad --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,15,21,33,37 --gpu-vendor-id=0x1002 --gpu-device-id=0x9615 --gpu-driver-vendor --gpu-driver-version
zqiang 28969 18.8 5.6 1090880 107904 ? Sl 16:52 0:11 /opt/chrome39/chrome --type=renderer --enable-deferred-image-decoding --lang=en-US --force-fieldtrials=UMA-Uniformity-Trial-100-Percent/group_01/ --renderer-print-preview --instant-process --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-delegated-renderer --enable-impl-side-painting --enable-gpu-rasterization --channel=18861.1.1215474539
zqiang 29570 6.0 3.4 976992 66768 ? Sl 16:52 0:03 /opt/chrome39/chrome --type=renderer --enable-deferred-image-decoding --lang=en-US --force-fieldtrials=UMA-Uniformity-Trial-100-Percent/group_01/ --extension-process --renderer-print-preview --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-delegated-renderer --enable-impl-side-painting --enable-gpu-rasterization --channel=18861.2.30735785
[zqiang@localhost ~]$

2)use "ps -aux | grep chrome" on the shell when the chrome39 browser is closed
[zqiang@localhost ~]$ ps -aux | grep chrome
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
zqiang 23409 0.0 0.0 2864 1008 ? S 16:52 0:00 /opt/chrome39/chrome-sandbox /opt/chrome39/chrome --type=zygote
zqiang 23415 9.6 2.6 363776 50832 ? S 16:52 0:10 /opt/chrome39/chrome --type=zygote
zqiang 26796 0.0 1.2 515328 23920 ? S 16:52 0:00 /opt/chrome39/chrome --type=zygote
zqiang 27229 0.0 0.0 102160 1392 pts/0 S+ 16:53 0:00 grep chrome
[zqiang@localhost ~]$

you can see still some process with --type=zygote is existed. Could you tell me why they can not be killed when close the browser,
Also, we found that: when close the browser, the ~ZygoteHostImpl() is called
ZygoteHostImpl::~ZygoteHostImpl()
{
TearDown();
}
so the TearDown function is also called, its inplemention is as follow:
void ZygoteHostImpl::TearDown() {
base::AutoLock lock(control_lock_);
if (control_fd_ > -1) {
// Closing the IPC channel will act as a notification to exit
// to the Zygote.
if (IGNORE_EINTR(close(control_fd_))) {
PLOG(ERROR) NOTREACHED();
}
control_fd_ = -1;
}
}

it seems like it should be exited, why is also existed?
your surggestions is quite appriciated, thank you very much!

Leave a comment

 
  • LISA15