-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
ReadClient crash when ExchangeManager is already shutdown (so trying to get SystemLayer fails) #20085
Comments
@mrjerryjohns @yunhanw-google Sounds like we should have canceled our timer much earlier than the destructor here.... |
What would the replication procedure be using |
I don't know about chip-repl, but for chip-tool I suspect this is not possible to replicate because it shuts down all its subscriptions manually before shutting down the stack. Note that this is a crash on the client side. |
Could |
I think that also shuts down all its subscriptions before shutting down the stack. But maybe we can hack it up to skip that step and see if that replicates... @krypton36 is that something you might have bandwidth for? |
This isn't a core SDK side problem. Application logic needs to correctly sequence shutting down their respective SDK allocated objects, which includes de-allocating an active ReadClient instance. |
Should However, it's clear that |
That's not workable given that we have read/subscribe APIs in |
Note that in this case the ReadClient is getting |
The destructor is what's getting called no, not Close? |
The destructor is getting called because Close got called, called the OnDone callback, and that is deleting the ReadClient. |
V1: review - needs follow up if this is platform specific or not and reproduction steps. In general, if a patch exists for this, it should be acceptable for 1.0 because it fixes a crash. |
This is not particularly platform-specific. Simplest reproduction steps are probably in #21811 (comment) using iOS CHIPTool (which does stack restarts in a controlled way, making this easy to reproduce) but similar steps could be designed for command-line chip-tool, I suspect, as evidenced by #22138 |
With #22282 and #22245 fixed, we are in a slightly better spot here. At this point commissioner shutdown will at least nix all the secure sessions early enough, which will trigger exchange timeouts for all the things that are waiting on a response. That leaves two things that can go wrong, as far as I can tell.
|
Problem
While Matter stack is shutdown, which causes subscription failure callback, if the ReadClient object for the subscription is deleted after the SystemLayer object is shutdown, dereferencing null object would cause a crash.
The following backtrace was seen:
Proposed Solution
In ReadClient::CancelLivenessCheckTimer(), check null before dereferencing SystemLayer() to call CancelTimer().
The text was updated successfully, but these errors were encountered: