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

Unified Diff: content/zygote/zygote_linux.cc

Issue 280303002: Add sandbox support for AsanCoverage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build error Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/zygote/zygote_linux.cc
diff --git a/content/zygote/zygote_linux.cc b/content/zygote/zygote_linux.cc
index b5186734de8ef82449bec27c0c9a12e90a0d24ec..e5e91296da7bc1873c9d25e6ee9a8a51ab3faed2 100644
--- a/content/zygote/zygote_linux.cc
+++ b/content/zygote/zygote_linux.cc
@@ -33,6 +33,10 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_switches.h"
+#if defined(ADDRESS_SANITIZER)
+#include <sanitizer/asan_interface.h>
+#endif
+
// See http://code.google.com/p/chromium/wiki/LinuxZygote
namespace content {
@@ -77,11 +81,14 @@ void KillAndReap(pid_t pid, ZygoteForkDelegate* helper) {
} // namespace
-Zygote::Zygote(int sandbox_flags, ScopedVector<ZygoteForkDelegate> helpers)
+Zygote::Zygote(int sandbox_flags, ScopedVector<ZygoteForkDelegate> helpers,
+ const std::vector<base::ProcessHandle>& extra_children,
+ const std::vector<int>& extra_fds)
: sandbox_flags_(sandbox_flags),
helpers_(helpers.Pass()),
- initial_uma_index_(0) {
-}
+ initial_uma_index_(0),
+ extra_children_(extra_children),
+ extra_fds_(extra_fds) {}
Zygote::~Zygote() {
}
@@ -147,6 +154,22 @@ bool Zygote::HandleRequestFromBrowser(int fd) {
if (len == 0 || (len == -1 && errno == ECONNRESET)) {
// EOF from the browser. We should die.
+ // TODO(earthdok): call __sanititizer_cov_dump() here to obtain code
+ // coverage for the Zygote. Currently it's not possible because of
+ // confusion over who is responsible for closing the file descriptor.
+ for (std::vector<int>::iterator it = extra_fds_.begin();
+ it < extra_fds_.end(); ++it) {
+ PCHECK(0 == IGNORE_EINTR(close(*it)));
+ }
+#if !defined(ADDRESS_SANITIZER)
+ // TODO(earthdok): add watchdog thread before using this in non-ASAN builds.
+ CHECK(extra_children_.empty());
+#endif
+ for (std::vector<base::ProcessHandle>::iterator it =
+ extra_children_.begin();
+ it < extra_children_.end(); ++it) {
+ PCHECK(*it == HANDLE_EINTR(waitpid(*it, NULL, 0)));
+ }
_exit(0);
return false;
}

Powered by Google App Engine
This is Rietveld 408576698