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

Unified Diff: components/nacl/loader/nacl_listener.cc

Issue 1117883002: Reduce resource leak code for StartNaClExecution. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « components/nacl/browser/nacl_process_host.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/nacl/loader/nacl_listener.cc
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc
index a451895fdd2f88da40c295de531cef1657a2538d..36412af3dc826fedd6e3ff9368fb101b0690f9fd 100644
--- a/components/nacl/loader/nacl_listener.cc
+++ b/components/nacl/loader/nacl_listener.cc
@@ -336,10 +336,23 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
}
NaClChromeMainSetUrandomFd(urandom_fd);
#endif
+
+ // Before starting the launching process, verify if FDs/HANDLEs are properly
+ // transferred to here.
+ // These can be stale, if some unexpected error happens in the sender
+ // process. It sends the IPC message regardless of the errors with deferring
+ // the error handle to the callee for releasing FDs/HANDLEs properly.
+ CHECK(params.nexe_file != IPC::InvalidPlatformFileForTransit());
+ CHECK(params.imc_bootstrap_handle != IPC::InvalidPlatformFileForTransit());
+ CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit());
+#if defined(OS_MACOSX)
+ CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit());
+#endif
+ CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle));
+
struct NaClApp* nap = NULL;
NaClChromeMainInit();
- CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle));
crash_info_shmem_.reset(new base::SharedMemory(
params.crash_info_shmem_handle, false /* not readonly */));
CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize));
@@ -402,13 +415,11 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
args->number_of_cores = number_of_cores_;
args->create_memory_object_func = CreateMemoryObject;
# if defined(OS_MACOSX)
- CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit());
g_shm_fd = IPC::PlatformFileForTransitToPlatformFile(params.mac_shm_fd);
# endif
#endif
DCHECK(params.process_type != nacl::kUnknownNaClProcessType);
- CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit());
NaClHandle irt_handle =
IPC::PlatformFileForTransitToPlatformFile(params.irt_handle);
@@ -432,7 +443,6 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
params.version);
}
- CHECK(params.imc_bootstrap_handle != IPC::InvalidPlatformFileForTransit());
args->imc_bootstrap_handle =
IPC::PlatformFileForTransitToPlatformFile(params.imc_bootstrap_handle);
args->enable_debug_stub = params.enable_debug_stub;
« no previous file with comments | « components/nacl/browser/nacl_process_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698