Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Issue 1715903002: Adapt upstream patches fixing potential deadlock in tcmalloc after fork.

Created:
4 years, 10 months ago by uzer
Modified:
4 years, 10 months ago
CC:
chromium-reviews, wfh+watch_chromium.org, Dai Mikurube (NOT FULLTIME), vmpstr+watch_chromium.org, rickyz (no longer on Chrome)
Base URL:
https://chromium.googlesource.com/chromium/src@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Adapt upstream patches fixing potential deadlock in tcmalloc after fork. This applies changes originally done in https://github.com/gperftools/gperftools/issues/499, which fix a bug causing Chromium deadlock at startup on Linux about once per 100 launches. This is due to lock in tcmalloc after fork() which is done in some libraries which Chromium depends on. For example, dbus contains this code: https://cgit.freedesktop.org/dbus/dbus/tree/dbus/dbus-sysdeps-unix.c#n4243 Here opendir() calls malloc() inside while running between fork() and exec(), leading to rare deadlock. Almost the same code is in glib: https://github.com/GNOME/glib/blob/de04fd13048dd208162573187e4c0d9e7d3428d3/glib/gspawn.c#L1041 BUG= R=wfh@chromium.org,jar@chromium.org

Patch Set 1 #

Patch Set 2 : Updated README #

Unified diffs Side-by-side diffs Delta from patch set Stats (+80 lines, -1 line) Patch
M base/allocator/BUILD.gn View 1 chunk +4 lines, -0 lines 0 comments Download
M base/allocator/allocator.gyp View 1 chunk +6 lines, -1 line 0 comments Download
M third_party/tcmalloc/README.chromium View 1 1 chunk +1 line, -0 lines 0 comments Download
M third_party/tcmalloc/chromium/src/central_freelist.h View 1 chunk +10 lines, -0 lines 0 comments Download
M third_party/tcmalloc/chromium/src/maybe_threads.h View 1 chunk +7 lines, -0 lines 0 comments Download
M third_party/tcmalloc/chromium/src/maybe_threads.cc View 3 chunks +14 lines, -0 lines 0 comments Download
M third_party/tcmalloc/chromium/src/static_vars.cc View 2 chunks +38 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (1 generated)
uzer
4 years, 10 months ago (2016-02-19 21:53:08 UTC) #1
jar (doing other things)
I'd suggest adding a reference to bug: https://bugs.chromium.org/p/chromium/issues/detail?id=570068 As I noted in that bug, this ...
4 years, 10 months ago (2016-02-19 23:50:28 UTC) #2
Tom Jakubowski
On 2016/02/19 23:50:28, jar (doing other things) wrote: > I'd suggest adding a reference to ...
4 years, 10 months ago (2016-02-20 00:50:16 UTC) #3
jar (doing other things)
I'm not familiar with the Zygote process.... ...but if it is running single threaded, then ...
4 years, 10 months ago (2016-02-20 02:30:35 UTC) #4
Will Harris
4 years, 10 months ago (2016-02-20 02:37:50 UTC) #6
On 2016/02/20 02:30:35, jar (doing other things) wrote:
> I'm not familiar with the Zygote process....
> 
> ...but if it is running single threaded, then there is no chance (no need?)
> of TCMalloc lock being held during the fork.... and the problem vanishes
> (with no risk of unexpected locking state in a child).
> 
> You have to do some plumbing to let this process create children as
> needed... that are controllable from main (which used to fork directly)....
> but that all seems (in my mind) to be a bunch of code and considerations.
> 
> Jim
> 
> On Fri, Feb 19, 2016 at 4:50 PM, <mailto:tjakubowski@oblong.com> wrote:
> 
> > On 2016/02/19 23:50:28, jar (doing other things) wrote:
> > > I'd suggest adding a reference to bug:
> > > https://bugs.chromium.org/p/chromium/issues/detail?id=570068
> > >
> > > As I noted in that bug, this has some potential for inducing more
deadlocks
> > than
> > > it resolves... so YMMV.
> > >
> > > As suggested in the bug, I'd argue for re-architecting the way that Chrome
> > > fork()s, to ensure that it *only* forks when single threaded.  To do this,
> we
> > > may need to create a single process (via fork) early on, and *that*
process
> > > would probably do all future forks (rather than using the main process).
> > >
> >
> > Doesn't the zygote process mostly fit this description? There is at least
one
> > exception, though: the fork that was consistently causing us issues as
> > embedders is the fork of the main process to adjust the OOM score of the
> > renderer process on Linux. See:
> >
>
https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/zy...
> >
>
https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/zy...
> > https://codereview.chromium.org/1715903002/
> >
> >
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Chromium-reviews" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email
> to mailto:chromium-reviews+unsubscribe@chromium.org.

Rickyz has a similar CL here - 

https://codereview.chromium.org/1523403003/

I think his is a bit less invasive - uzer can you take a look and see if that
cleanly applies and fixes your issue?

Powered by Google App Engine
This is Rietveld 408576698