-
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
Remove acquiring matter context lock for canceling TimerExpiredCallback #26578
Merged
tehampson
merged 2 commits into
project-chip:master
from
tehampson:ble-cancel-timer-no-lock
May 16, 2023
Merged
Remove acquiring matter context lock for canceling TimerExpiredCallback #26578
tehampson
merged 2 commits into
project-chip:master
from
tehampson:ble-cancel-timer-no-lock
May 16, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pullapprove
bot
requested review from
amitnj,
andy31415,
anush-apple,
arkq,
bzbarsky-apple,
carol-apple,
chrisdecenzo,
chshu,
chulspro,
cliffamzn,
CodeChronos928,
Damian-Nordic,
dhrishi,
electrocucaracha,
franck-apple,
gjc13,
harimau-qirex,
harsha-rajendran,
hawk248,
jelderton,
jepenven-silabs,
jmartinez-silabs,
jmeg-sfy,
joonhaengHeo,
jtung-apple and
kcoppock
May 15, 2023 15:07
pullapprove
bot
requested review from
ksperling-apple,
lazarkov,
lpbeliveau-silabs,
LuDuda,
mlepage-google,
mrjerryjohns,
msandstedt,
mspang,
nivi-apple,
robszewczyk,
saurabhst,
selissia,
sharadb-amazon,
tcarmelveilleux,
tecimovic,
turon,
vijs,
vivien-apple,
woody-apple,
xylophone21 and
younghak-hwang
May 15, 2023 15:07
PR #26578: Size comparison from b4fb147 to 46768f9 Increases (8 builds for bl602, psoc6, telink)
Decreases (16 builds for bl702, esp32, linux, nrfconnect, psoc6, telink)
Full report (57 builds for bl602, bl702, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
andy31415
approved these changes
May 15, 2023
jmartinez-silabs
approved these changes
May 15, 2023
tehampson
commented
May 15, 2023
tianfeng-yang
pushed a commit
to tianfeng-yang/connectedhomeip
that referenced
this pull request
May 17, 2023
…ck (project-chip#26578) * Remove acquiring matter context lock for canceling TimerExpiredCallback * Update comment to reflect update to code
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #26516
BLEManagerImpl::InitiateScan(BleScanState scanType)
is scheduled work, and therefore runs in the matter context. On the linemDeviceScanner = Internal::ChipDeviceScanner::Create(mpEndpoint->mpAdapter, this);
it is possible, for destructorChipDeviceScanner::~ChipDeviceScanner()
to be called if there was previously anmDeviceScanner
assigned. While most cases it is fine as the timer has already expired and thereforeCancelTimer
is not called. If there are back to backBleLayer::NewBleConnection*
calls where the timer doesn't expire and you can get a deadlock.This corner case is only possible to encounter if you are using chip-tool interactive or chip-repl, in a very particular way.
In previous PRs, I was attempting to fix segfaults and deadlock reported by various users under different usecases in a timely fashion. In one of these earlier PR iterations, while attempted to fix segfaults and deadlocks, the
LockChipStack()
andUnlockChipStack()
was introduced as we knew for a fact that it was called in a thread not holding the matter context. But, since that lock acquisition code was added, even in that original use case, this destructor would be called from thread from a thread already holding the matter context. It just was not immediately caught as the timer has already expired andmTimerExpired
was false.Test:
chip-tool pairing ble-wifi 1 asdf asdf 20202021 3840
, no longer deadlockschip-repl
issuingasdf = chip.ble.DiscoverSync(timeoutMs=2000)
followed byfor x in asdf: print(f"TMsg {x}")
works.chip-repl
, issuingdevCtrl.CommissionWiFi(3840, 20202021, 1, "asdf", "asdf")
no longer deadlocks.In each of the above 3 tests I attempted to perform
SIGINT
, and kill running application prior to