Commit 73f39a66 authored by sadrul's avatar sadrul Committed by Commit bot

content: Change how a bad message from a child is logged.

Instead of always logging the message ID, log a custom error string.
This is necessary for when the messages are converted to mojo messages,
where the messages do not have a corresponding ID.

BUG=643746

Review-Url: https://codereview.chromium.org/2624613003
Cr-Commit-Position: refs/heads/master@{#442790}
parent ef384367
...@@ -373,18 +373,19 @@ void BrowserChildProcessHostImpl::OnChannelError() { ...@@ -373,18 +373,19 @@ void BrowserChildProcessHostImpl::OnChannelError() {
void BrowserChildProcessHostImpl::OnBadMessageReceived( void BrowserChildProcessHostImpl::OnBadMessageReceived(
const IPC::Message& message) { const IPC::Message& message) {
TerminateOnBadMessageReceived(message.type()); std::string log_message =
base::StringPrintf("Bad message received of type: %u", message.type());
TerminateOnBadMessageReceived(log_message);
} }
void BrowserChildProcessHostImpl::TerminateOnBadMessageReceived(uint32_t type) { void BrowserChildProcessHostImpl::TerminateOnBadMessageReceived(
const std::string& error) {
HistogramBadMessageTerminated(data_.process_type); HistogramBadMessageTerminated(data_.process_type);
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableKillAfterBadIPC)) { switches::kDisableKillAfterBadIPC)) {
return; return;
} }
LOG(ERROR) << "Terminating child process for bad IPC message of type " LOG(ERROR) << "Terminating child process for bad IPC message: " << error;
<< type;
// Create a memory dump. This will contain enough stack frames to work out // Create a memory dump. This will contain enough stack frames to work out
// what the bad message was. // what the bad message was.
base::debug::DumpWithoutCrashing(); base::debug::DumpWithoutCrashing();
......
...@@ -92,9 +92,9 @@ class CONTENT_EXPORT BrowserChildProcessHostImpl ...@@ -92,9 +92,9 @@ class CONTENT_EXPORT BrowserChildProcessHostImpl
void OnChannelError() override; void OnChannelError() override;
void OnBadMessageReceived(const IPC::Message& message) override; void OnBadMessageReceived(const IPC::Message& message) override;
// Terminates the process and logs an error after a bad message was received // Terminates the process and logs a stack trace after a bad message was
// from the child process. // received from the child process.
void TerminateOnBadMessageReceived(uint32_t type); void TerminateOnBadMessageReceived(const std::string& error);
// Removes this host from the host list. Calls ChildProcessHost::ForceShutdown // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown
void ForceShutdown(); void ForceShutdown();
......
...@@ -691,6 +691,7 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { ...@@ -691,6 +691,7 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) {
void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow(
gpu::SurfaceHandle parent_handle, gpu::SurfaceHandle parent_handle,
gpu::SurfaceHandle window_handle) { gpu::SurfaceHandle window_handle) {
constexpr char kBadMessageError[] = "Bad parenting request from gpu process.";
if (!in_process_) { if (!in_process_) {
DCHECK(process_); DCHECK(process_);
{ {
...@@ -698,8 +699,7 @@ void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( ...@@ -698,8 +699,7 @@ void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow(
DWORD thread_id = GetWindowThreadProcessId(parent_handle, &process_id); DWORD thread_id = GetWindowThreadProcessId(parent_handle, &process_id);
if (!thread_id || process_id != ::GetCurrentProcessId()) { if (!thread_id || process_id != ::GetCurrentProcessId()) {
process_->TerminateOnBadMessageReceived( process_->TerminateOnBadMessageReceived(kBadMessageError);
GpuHostMsg_AcceleratedSurfaceCreatedChildWindow::ID);
return; return;
} }
} }
...@@ -709,8 +709,7 @@ void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( ...@@ -709,8 +709,7 @@ void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow(
DWORD thread_id = GetWindowThreadProcessId(window_handle, &process_id); DWORD thread_id = GetWindowThreadProcessId(window_handle, &process_id);
if (!thread_id || process_id != process_->GetProcess().Pid()) { if (!thread_id || process_id != process_->GetProcess().Pid()) {
process_->TerminateOnBadMessageReceived( process_->TerminateOnBadMessageReceived(kBadMessageError);
GpuHostMsg_AcceleratedSurfaceCreatedChildWindow::ID);
return; return;
} }
} }
...@@ -718,8 +717,7 @@ void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow( ...@@ -718,8 +717,7 @@ void GpuProcessHost::OnAcceleratedSurfaceCreatedChildWindow(
if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild( if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(
parent_handle, window_handle)) { parent_handle, window_handle)) {
process_->TerminateOnBadMessageReceived( process_->TerminateOnBadMessageReceived(kBadMessageError);
GpuHostMsg_AcceleratedSurfaceCreatedChildWindow::ID);
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment