Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Calling StopPairing during secure kSecurePairing (device discovery) does not work correctly #25724

Open
caipiblack opened this issue Mar 17, 2023 · 1 comment
Assignees

Comments

@caipiblack
Copy link
Contributor

Reproduction steps

This isssue is similar to #25708

  1. Use the matter stack to start a commissioning
  2. When the commissioning is at the step kSecurePairing (device discovery) call this function to stop the commissioning:
CurrentCommissioner().StopPairing(idOfNodeBeingPaired);
  1. Start a new commissioning and make it failing (device offline)

At this point:

  1. The first commissioning will be stopped, but some variables are not cleaned
  2. The second commissioning will never be informed about failures via pairing delegate, because mWaitingForPASE keep the old value (true), so when we arrive in the function SetUpCodePairer::OnDeviceDiscoveredTimeoutCallback(), the function pairer->mCommissioner->OnSessionEstablishmentError(err); is never called.
void SetUpCodePairer::OnDeviceDiscoveredTimeoutCallback(System::Layer * layer, void * context)
{
    ChipLogError(Controller, "Discovery timed out");
    auto * pairer = static_cast<SetUpCodePairer *>(context);
    ChipLogProgress(Controller, "  -> StopConnectOverBle()");
    LogErrorOnFailure(pairer->StopConnectOverBle());
    ChipLogProgress(Controller, "  -> StopConnectOverIP()");
    LogErrorOnFailure(pairer->StopConnectOverIP());
    ChipLogProgress(Controller, "  -> StopConnectOverSoftAP()");
    LogErrorOnFailure(pairer->StopConnectOverSoftAP());
    
    ChipLogProgress(Controller, "  -> pairer->mWaitingForPASE = %d", pairer->mWaitingForPASE);
    ChipLogProgress(Controller, "  -> pairer->mDiscoveredParameters.empty()");
    
    if (!pairer->mWaitingForPASE && pairer->mDiscoveredParameters.empty())
    {
        ChipLogProgress(Controller, "  -> ready to notify..");
        // We're not waiting on any more PASE attempts, and we're not going to
        // discover anything at this point, so we should just notify our
        // listener.
        CHIP_ERROR err = pairer->mLastPASEError;
        if (err == CHIP_NO_ERROR)
        {
            err = CHIP_ERROR_TIMEOUT;
        }
        ChipLogProgress(Controller, "  -> OnSessionEstablishmentError()..");
        pairer->mCommissioner->OnSessionEstablishmentError(err);
        ChipLogProgress(Controller, "  -> Done.");
    }
}

Note: There are probably more variables that are not cleaned.

Bug prevalence

Everytime

GitHub hash of the SDK that was being used

v1.0.0

Platform

other

Platform Version(s)

Linux

Anything else?

This problem is just "hard" to reproduce because:

  • With chip-tool, by construction you can't start a new command if the previous one is not finished (also in interactive mode)
  • So if the "StopPairing()" was accessible you will not be able to call it ..

The unique way to reproduce is to modify chip-tool, or use your own commissioner..

Thats the unique difficulty to reproduce the problem

@stale
Copy link

stale bot commented Sep 17, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants