New issue
Advanced search Search tips

Issue 616192 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

PostTask in constructor of a RefCountedThreadSafe object?

Project Member Reported by yuweih@chromium.org, May 31 2016

Issue description

Recently we have found a piece of code that randomly crashes the Chromoting Android App:

ChromotingJniInstance::ChromotingJniInstance(...) {
  // Initializations...
  jni_runtime_->network_task_runner()->PostTask(
      FROM_HERE,
      base::Bind(&ChromotingJniInstance::ConnectToHostOnNetworkThread, this));
}

Occasionally the object will be destructed right after it is constructed, triggered by the dtor of BindState. It turns out the object is initialized with refcount 0 and raised to 1 by base::Bind and occasionally the task will be done earlier than the assignment operator that normally raises the refcount to 1, causing it to be destructed too early.

Currently there is no documentation or comment about (not) posting tasks or generally using |this| inside the constructor. I think you guys should either write some comments about this or consider this as a bug?
 

Sign in to add a comment