New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 730608 link

Starred by 2 users

Issue metadata

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



Sign in to add a comment

CronetEngine.stopNetLog() looks racy, like it could hang

Project Member Reported by pauljensen@chromium.org, Jun 7 2017

Issue description

    @Override
    public void stopNetLog() {
        synchronized (mLock) {
            if (!mIsLogging) {
                return;
            }
            checkHaveAdapter();
            mStopNetLogCompleted = new ConditionVariable();
            nativeStopNetLog(mUrlRequestContextAdapter);
            mIsLogging = false;
        }
        mStopNetLogCompleted.block();
    }

    @CalledByNative
    public void stopNetLogCompleted() {
        mStopNetLogCompleted.open();
    }

I imagine a hang looking like:
1. on thread #1: CronetEngine.startNetLog() called.
2. on thread #1: CronetEngine.stopNetLog() called, left waiting on mStopNetLogCompleted.block().
3. on thread #2: CronetEngine.startNetLog() called.
4. on thread #2: CronetEngine.stopNetLog() called, resets mStopNetLogCompleted to a new ConditionVariable.
Now thread #1 is left waiting forever.  stopNetLogCompleted() will open the second ConditionVariable created in step #4.
 
I think a potential solution is to pass mStopNetLogCompleted to nativeStopNetLog() (and back to stopNetLogCompleted()) and remove mStopNetLogCompleted from CronetUrlRequestContext.
Labels: -Pri-2 Pri-3
Cc: kapishnikov@chromium.org
 Issue 711652  has been merged into this issue.

Sign in to add a comment