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

Issue 672003: POSIX: don't allocate memory after forking. (Closed)

Created:
10 years, 9 months ago by agl
Modified:
9 years, 7 months ago
CC:
chromium-reviews_googlegroups.com, brettw+cc_chromium.org, pam+watch_chromium.org, John Grabowski, Paweł Hajdan Jr.
Visibility:
Public.

Description

POSIX: don't allocate memory after forking. Previously we would allocate memory in the child process. However, the allocation might have happened while the malloc lock was held, resulting in a deadlock. This patch removes allocation from the child but probably makes Mac's startup time slower until a Mac person can implement dir_reader_posix.h. TEST=Unittest for new code BUG=36678

Patch Set 1 #

Patch Set 2 : ... #

Total comments: 7

Patch Set 3 : ... #

Total comments: 52

Patch Set 4 : ... #

Patch Set 5 : ... #

Total comments: 21

Patch Set 6 : ... #

Unified diffs Side-by-side diffs Delta from patch set Stats (+497 lines, -117 lines) Patch
M base/base.gyp View 1 2 3 4 5 3 chunks +3 lines, -1 line 0 comments Download
M base/base.gypi View 5 1 chunk +3 lines, -0 lines 0 comments Download
A base/dir_reader_fallback.h View 4 5 1 chunk +30 lines, -0 lines 0 comments Download
A base/dir_reader_linux.h View 1 2 3 4 5 1 chunk +97 lines, -0 lines 0 comments Download
A base/dir_reader_posix.h View 1 2 3 4 5 1 chunk +30 lines, -0 lines 0 comments Download
A base/dir_reader_posix_unittest.cc View 1 2 3 1 chunk +91 lines, -0 lines 0 comments Download
M base/file_descriptor_shuffle.h View 1 chunk +6 lines, -2 lines 0 comments Download
M base/file_descriptor_shuffle.cc View 1 2 3 2 chunks +24 lines, -12 lines 0 comments Download
M base/process_util.h View 1 chunk +0 lines, -6 lines 0 comments Download
M base/process_util_posix.cc View 1 2 3 4 5 12 chunks +176 lines, -96 lines 0 comments Download
M base/process_util_unittest.cc View 1 chunk +37 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
agl
10 years, 9 months ago (2010-03-08 21:18:13 UTC) #1
Paweł Hajdan Jr.
Drive-by with some test-related comments. http://codereview.chromium.org/672003/diff/9/1011 File base/dir_reader_posix_unittest.cc (right): http://codereview.chromium.org/672003/diff/9/1011#newcode17 base/dir_reader_posix_unittest.cc:17: namespace { nit: Why ...
10 years, 9 months ago (2010-03-08 21:22:28 UTC) #2
agl
http://codereview.chromium.org/672003/diff/9/1011 File base/dir_reader_posix_unittest.cc (right): http://codereview.chromium.org/672003/diff/9/1011#newcode17 base/dir_reader_posix_unittest.cc:17: namespace { On 2010/03/08 21:22:28, Paweł Hajdan Jr. wrote: ...
10 years, 9 months ago (2010-03-08 21:42:23 UTC) #3
willchan no longer on Chromium
Should there also be a base.gypi change to add the new dir_reader_*.h files? http://codereview.chromium.org/672003/diff/11/13 File ...
10 years, 9 months ago (2010-03-09 00:32:40 UTC) #4
Paweł Hajdan Jr.
The bits I commented in the drive-by LGTM
10 years, 9 months ago (2010-03-09 06:37:28 UTC) #5
agl
PTAL http://codereview.chromium.org/672003/diff/11/13 File base/dir_reader_linux.h (right): http://codereview.chromium.org/672003/diff/11/13#newcode5 base/dir_reader_linux.h:5: #ifndef BASE_DIR_READER_LINUX_H On 2010/03/09 00:32:40, willchan wrote: > ...
10 years, 9 months ago (2010-03-09 18:56:12 UTC) #6
willchan no longer on Chromium
Am I looking at an old version? I don't see how AlterEnvironment affects the child ...
10 years, 9 months ago (2010-03-09 20:18:22 UTC) #7
agl
http://codereview.chromium.org/672003/diff/11001/12003 File base/dir_reader_fallback.h (right): http://codereview.chromium.org/672003/diff/11001/12003#newcode30 base/dir_reader_fallback.h:30: #endif // !BASE_DIR_READER_FALLBACK_H_ On 2010/03/09 20:18:22, willchan wrote: > ...
10 years, 9 months ago (2010-03-09 20:32:03 UTC) #8
willchan no longer on Chromium
10 years, 9 months ago (2010-03-09 20:39:28 UTC) #9
http://codereview.chromium.org/672003/diff/11001/12010
File base/process_util_posix.cc (right):

http://codereview.chromium.org/672003/diff/11001/12010#newcode487
base/process_util_posix.cc:487: environ = new_environ.get();
On 2010/03/09 20:32:03, agl wrote:
> On 2010/03/09 20:18:22, willchan wrote:
> > Is there a purpose to this environ variable?  How does this compile?  I
don't
> > see the definition for environ now.
> 
> It's defined by POSIX to the global environment.

Ah, I missed that.  I saw that it was a parameter before, so I thought it was
leftover from that.

So, is AlterEnvironment() safe?  We're modifying a global variable without
acquiring/releasing locks, which is what setenv() and unsetenv() do.  Also,
AlterEnvironment() is called prior to fork().  Is there something that is
undoing setting the environment?  And is modifying the parent's environment
reasonable?  What if another thread is using getenv()?

I was thinking that we might want to use execve() instead and write a new
frontend for it that does the same path search that execvp() does.

Powered by Google App Engine
This is Rietveld 408576698