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

Cleanup CASESession and PASESession lifetime #13357

Merged
merged 9 commits into from
Jan 7, 2022

Conversation

msandstedt
Copy link
Contributor

Problem

CASESession and PASESession objects cannot be freed or reused when OnSessionEstablished and OnSessionEstablishmentError delegate methods are executed. Instead, historically, code needed to wait for one more iteration of the event loop before freeing or reusing these objects.

This was in part due to the problem identified in and fixed by #12794, where these objects needed to persist in order for the ExchangeMessageDispatch::SendMessage call for the final ACK of session establishment to be sent. Instead, with #12794, SendMessage uses the SessionEstablishmentExchangeDispatch global singleton.

But there are two other things that prevent immediate free or reuse of the CASESession and PASESession objects on execution of completion callbacks: these objects clear their references to their exchange contexts at completion, but do not clear themselves as delegates to their exchange contexts. The object's methods can also continue to access instance memory after execution of the callbacks.

Change overview

This commit adds code to CASESession and PASESession to always clear themselves as delegates to their exchange contexts before clearing their references to their exchange contexts, and reorders calls to mDelegate->OnSessionEstablished and mDelegate->OnSessionEstablishmentError to occur last in any given method
in case mDelegate frees or reuses the CASESession or PASESession objects on execution of the completion callbacks.

Additionally, this removes the code in the OperationalDeviceProxy that was deferring release of the CASESession object until after an iteration of the event loop. Now when OnSessionEstablished fires, the CASESession can be reused or discarded immediately.

Fixes #13146

Testing

TestCASESession, TestPASESession and all other unit tests pass. We also expect asan to show clean CI runs with this.

This was also manually tested and seen to fix #13146 in the original feature branch for #13294 where this problem had first been identified.

@msandstedt
Copy link
Contributor Author

@gjc13 ,

This PR removes a workaround introduced in #12148, where release of CASESession needed to be deferred.

Please take a look if you are able.

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

PR #13357: Size comparison from 36a759d to 6dc903d

Increases (13 builds for efr32, k32w, linux, p6, qpg, telink)
platform target config section 36a759d 6dc903d change % change
efr32 lighting-app BRD4161A (read only) 831968 832336 368 0.0
.text 831960 832328 368 0.0
BRD4161A+rpc (read only) 819148 819964 816 0.1
.text 819140 819956 816 0.1
window-app BRD4161A (read only) 805416 805784 368 0.0
.text 805408 805776 368 0.0
k32w light k32w061+release (read/write) 655772 655820 48 0.0
.text 571260 571308 48 0.0
lock k32w061+release (read/write) 660032 660080 48 0.0
.text 575204 575252 48 0.0
linux chip-tool-ipv6only arm64 (read only) 7033996 7034236 240 0.0
.text 5956932 5957188 256 0.0
thermostat-no-ble arm64 (read only) 2031036 2031308 272 0.0
.text 1689280 1689584 304 0.0
p6 all-clusters-app default (read/write) 2404872 2404904 32 0.0
.text 1363136 1363168 32 0.0
light-app default (read/write) 2326832 2326880 48 0.0
.text 1285096 1285144 48 0.0
lock-app default (read/write) 2299032 2299080 48 0.0
.text 1257296 1257344 48 0.0
qpg lighting-app qpg6105+debug (read only) 533268 533308 40 0.0
.text 527948 527988 40 0.0
lock-app qpg6105+debug (read only) 505044 505084 40 0.0
.text 499724 499764 40 0.0
telink lighting-app tlsr9518adk80d (read/write) 834102 834150 48 0.0
text 582240 582292 52 0.0
Decreases (2 builds for linux)
platform target config section 36a759d 6dc903d change % change
linux chip-tool-ipv6only arm64 .got 56992 56984 -8 -0.0
thermostat-no-ble arm64 (read/write) 144193 144177 -16 -0.0
.got 3952 3944 -8 -0.2
Full report (14 builds for efr32, k32w, linux, p6, qpg, telink)
platform target config section 36a759d 6dc903d change % change
efr32 lighting-app BRD4161A (read only) 831968 832336 368 0.0
(read/write) 127088 127088 0 0.0
.bss 125208 125208 0 0.0
.data 1876 1876 0 0.0
.text 831960 832328 368 0.0
BRD4161A+rpc (read only) 819148 819964 816 0.1
(read/write) 143744 143744 0 0.0
.bss 141768 141768 0 0.0
.data 1976 1976 0 0.0
.text 819140 819956 816 0.1
window-app BRD4161A (read only) 805416 805784 368 0.0
(read/write) 126024 126024 0 0.0
.bss 124192 124192 0 0.0
.data 1832 1832 0 0.0
.text 805408 805776 368 0.0
k32w light k32w061+release (read/write) 655772 655820 48 0.0
.bss 76864 76864 0 0.0
.data 1848 1848 0 0.0
.text 571260 571308 48 0.0
lock k32w061+release (read/write) 660032 660080 48 0.0
.bss 77160 77160 0 0.0
.data 1868 1868 0 0.0
.text 575204 575252 48 0.0
linux chip-tool-ipv6only arm64 (read only) 7033996 7034236 240 0.0
(read/write) 325073 325073 0 0.0
.bss 54241 54241 0 0.0
.data 1096 1096 0 0.0
.data.rel.ro 209064 209064 0 0.0
.dynamic 560 560 0 0.0
.got 56992 56984 -8 -0.0
.init 24 24 0 0.0
.init_array 168 168 0 0.0
.rodata 384292 384292 0 0.0
.text 5956932 5957188 256 0.0
thermostat-no-ble arm64 (read only) 2031036 2031308 272 0.0
(read/write) 144193 144177 -16 -0.0
.bss 64033 64033 0 0.0
.data 880 880 0 0.0
.data.rel.ro 72392 72392 0 0.0
.dynamic 560 560 0 0.0
.got 3952 3944 -8 -0.2
.init 24 24 0 0.0
.init_array 296 296 0 0.0
.rodata 128844 128844 0 0.0
.text 1689280 1689584 304 0.0
p6 all-clusters-app default (read/write) 2404872 2404904 32 0.0
.bss 117020 117020 0 0.0
.data 2592 2592 0 0.0
.text 1363136 1363168 32 0.0
light-app default (read/write) 2326832 2326880 48 0.0
.bss 105888 105888 0 0.0
.data 2384 2384 0 0.0
.text 1285096 1285144 48 0.0
lock-app default (read/write) 2299032 2299080 48 0.0
.bss 104768 104768 0 0.0
.data 2336 2336 0 0.0
.text 1257296 1257344 48 0.0
qpg lighting-app qpg6105+debug (read only) 533268 533308 40 0.0
(read/write) 146936 146936 0 0.0
.bss 86688 86688 0 0.0
.data 1004 1004 0 0.0
.text 527948 527988 40 0.0
lock-app qpg6105+debug (read only) 505044 505084 40 0.0
(read/write) 146940 146940 0 0.0
.bss 85824 85824 0 0.0
.data 952 952 0 0.0
.text 499724 499764 40 0.0
persistent-storage-app qpg6105+debug (read only) 106448 106448 0 0.0
(read/write) 146938 146938 0 0.0
.bss 36146 36146 0 0.0
.data 288 288 0 0.0
.text 101128 101128 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 834102 834150 48 0.0
bss 86864 86864 0 0.0
noinit 37160 37160 0 0.0
text 582240 582292 52 0.0

src/app/OperationalDeviceProxy.cpp Outdated Show resolved Hide resolved
src/app/OperationalDeviceProxy.cpp Outdated Show resolved Hide resolved
src/protocols/secure_channel/CASESession.cpp Outdated Show resolved Hide resolved
src/protocols/secure_channel/CASESession.cpp Outdated Show resolved Hide resolved
@bzbarsky-apple
Copy link
Contributor

I wonder whether we should factor out this two-call sequence, with the comments, into a helper method...

In fact, maybe mExchangeContext should move up to PairingSession, and the helper method should live there? Followup probably better for that sort of refactoring.

@msandstedt
Copy link
Contributor Author

I wonder whether we should factor out this two-call sequence, with the comments, into a helper method...

In fact, maybe mExchangeContext should move up to PairingSession, and the helper method should live there? Followup probably better for that sort of refactoring.

It would be my preference not to do this in this PR.

Copy link
Contributor

@bzbarsky-apple bzbarsky-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but let's do a followup to consolidate the must-be-done-just-so code.

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

PR #13357: Size comparison from 36a759d to 3d04424

Increases above 0.2%:

platform target config section 36a759d 3d04424 change % change
mbed pigweed-app CY8CPROTO_062_4343W+release .text 103096 103392 296 0.3
Increases (17 builds for efr32, k32w, linux, mbed, p6, qpg, telink)
platform target config section 36a759d 3d04424 change % change
efr32 lighting-app BRD4161A (read only) 831968 832368 400 0.0
.text 831960 832360 400 0.0
BRD4161A+rpc (read only) 819148 819996 848 0.1
.text 819140 819988 848 0.1
window-app BRD4161A (read only) 805416 805816 400 0.0
.text 805408 805808 400 0.0
k32w light k32w061+release (read/write) 655772 655836 64 0.0
.text 571260 571324 64 0.0
lock k32w061+release (read/write) 660032 660096 64 0.0
.text 575204 575268 64 0.0
linux chip-tool-ipv6only arm64 (read only) 7033996 7034412 416 0.0
.text 5956932 5957364 432 0.0
thermostat-no-ble arm64 (read only) 2031036 2031452 416 0.0
.text 1689280 1689728 448 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read/write) 2349024 2349088 64 0.0
.text 1311600 1311664 64 0.0
lighting-app CY8CPROTO_062_4343W+release (read/write) 2330912 2331272 360 0.0
.text 1293512 1293872 360 0.0
lock-app CY8CPROTO_062_4343W+release (read/write) 2304072 2304432 360 0.0
.text 1266672 1267032 360 0.0
pigweed-app CY8CPROTO_062_4343W+release (read/write) 1139712 1140008 296 0.0
.text 103096 103392 296 0.3
p6 all-clusters-app default (read/write) 2404872 2404936 64 0.0
.text 1363136 1363200 64 0.0
light-app default (read/write) 2326832 2326912 80 0.0
.text 1285096 1285176 80 0.0
lock-app default (read/write) 2299032 2299112 80 0.0
.text 1257296 1257376 80 0.0
qpg lighting-app qpg6105+debug (read only) 533268 533332 64 0.0
.text 527948 528012 64 0.0
lock-app qpg6105+debug (read only) 505044 505108 64 0.0
.text 499724 499788 64 0.0
telink lighting-app tlsr9518adk80d (read/write) 834102 834174 72 0.0
text 582240 582314 74 0.0
Decreases (2 builds for linux)
platform target config section 36a759d 3d04424 change % change
linux chip-tool-ipv6only arm64 .got 56992 56984 -8 -0.0
thermostat-no-ble arm64 (read/write) 144193 144177 -16 -0.0
.got 3952 3944 -8 -0.2
Full report (19 builds for efr32, k32w, linux, mbed, p6, qpg, telink)
platform target config section 36a759d 3d04424 change % change
efr32 lighting-app BRD4161A (read only) 831968 832368 400 0.0
(read/write) 127088 127088 0 0.0
.bss 125208 125208 0 0.0
.data 1876 1876 0 0.0
.text 831960 832360 400 0.0
BRD4161A+rpc (read only) 819148 819996 848 0.1
(read/write) 143744 143744 0 0.0
.bss 141768 141768 0 0.0
.data 1976 1976 0 0.0
.text 819140 819988 848 0.1
window-app BRD4161A (read only) 805416 805816 400 0.0
(read/write) 126024 126024 0 0.0
.bss 124192 124192 0 0.0
.data 1832 1832 0 0.0
.text 805408 805808 400 0.0
k32w light k32w061+release (read/write) 655772 655836 64 0.0
.bss 76864 76864 0 0.0
.data 1848 1848 0 0.0
.text 571260 571324 64 0.0
lock k32w061+release (read/write) 660032 660096 64 0.0
.bss 77160 77160 0 0.0
.data 1868 1868 0 0.0
.text 575204 575268 64 0.0
linux chip-tool-ipv6only arm64 (read only) 7033996 7034412 416 0.0
(read/write) 325073 325073 0 0.0
.bss 54241 54241 0 0.0
.data 1096 1096 0 0.0
.data.rel.ro 209064 209064 0 0.0
.dynamic 560 560 0 0.0
.got 56992 56984 -8 -0.0
.init 24 24 0 0.0
.init_array 168 168 0 0.0
.rodata 384292 384292 0 0.0
.text 5956932 5957364 432 0.0
thermostat-no-ble arm64 (read only) 2031036 2031452 416 0.0
(read/write) 144193 144177 -16 -0.0
.bss 64033 64033 0 0.0
.data 880 880 0 0.0
.data.rel.ro 72392 72392 0 0.0
.dynamic 560 560 0 0.0
.got 3952 3944 -8 -0.2
.init 24 24 0 0.0
.init_array 296 296 0 0.0
.rodata 128844 128844 0 0.0
.text 1689280 1689728 448 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2349024 2349088 64 0.0
.bss 188812 188812 0 0.0
.data 5312 5312 0 0.0
.text 1311600 1311664 64 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2330912 2331272 360 0.0
.bss 180632 180632 0 0.0
.data 5552 5552 0 0.0
.text 1293512 1293872 360 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2304072 2304432 360 0.0
.bss 179680 179680 0 0.0
.data 5544 5544 0 0.0
.text 1266672 1267032 360 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139712 1140008 296 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103096 103392 296 0.3
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2053888 2053888 0 0.0
.bss 156972 156972 0 0.0
.data 4864 4864 0 0.0
.text 1016488 1016488 0 0.0
p6 all-clusters-app default (read/write) 2404872 2404936 64 0.0
.bss 117020 117020 0 0.0
.data 2592 2592 0 0.0
.text 1363136 1363200 64 0.0
light-app default (read/write) 2326832 2326912 80 0.0
.bss 105888 105888 0 0.0
.data 2384 2384 0 0.0
.text 1285096 1285176 80 0.0
lock-app default (read/write) 2299032 2299112 80 0.0
.bss 104768 104768 0 0.0
.data 2336 2336 0 0.0
.text 1257296 1257376 80 0.0
qpg lighting-app qpg6105+debug (read only) 533268 533332 64 0.0
(read/write) 146936 146936 0 0.0
.bss 86688 86688 0 0.0
.data 1004 1004 0 0.0
.text 527948 528012 64 0.0
lock-app qpg6105+debug (read only) 505044 505108 64 0.0
(read/write) 146940 146940 0 0.0
.bss 85824 85824 0 0.0
.data 952 952 0 0.0
.text 499724 499788 64 0.0
persistent-storage-app qpg6105+debug (read only) 106448 106448 0 0.0
(read/write) 146938 146938 0 0.0
.bss 36146 36146 0 0.0
.data 288 288 0 0.0
.text 101128 101128 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 834102 834174 72 0.0
bss 86864 86864 0 0.0
noinit 37160 37160 0 0.0
text 582240 582314 74 0.0

@andy31415
Copy link
Contributor

@msandstedt - conflicts

@msandstedt
Copy link
Contributor Author

@msandstedt - conflicts

Conflicts are fixed. Now just need to fix top of tree...

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

PR #13357: Size comparison from 585cdcb to caf19ce

Increases (13 builds for efr32, k32w, linux, p6, qpg, telink)
platform target config section 585cdcb caf19ce change % change
efr32 lighting-app BRD4161A (read only) 828876 829228 352 0.0
.text 828868 829220 352 0.0
BRD4161A+rpc (read only) 816072 816872 800 0.1
.text 816064 816864 800 0.1
window-app BRD4161A (read only) 802324 802676 352 0.0
.text 802316 802668 352 0.0
k32w light k32w061+release (read/write) 655308 655324 16 0.0
.text 570884 570900 16 0.0
lock k32w061+release (read/write) 659584 659600 16 0.0
.text 574844 574860 16 0.0
linux chip-tool-ipv6only arm64 (read only) 7039468 7039740 272 0.0
.text 5961492 5961796 304 0.0
thermostat-no-ble arm64 (read only) 2033468 2033788 320 0.0
.text 1690800 1691152 352 0.0
p6 all-clusters-app default (read/write) 2401624 2401640 16 0.0
.text 1359888 1359904 16 0.0
light-app default (read/write) 2323648 2323664 16 0.0
.text 1281912 1281928 16 0.0
lock-app default (read/write) 2295872 2295888 16 0.0
.text 1254136 1254152 16 0.0
qpg lighting-app qpg6105+debug (read only) 533160 533176 16 0.0
.text 527840 527856 16 0.0
lock-app qpg6105+debug (read only) 504936 504952 16 0.0
.text 499616 499632 16 0.0
telink lighting-app tlsr9518adk80d (read/write) 834466 834506 40 0.0
text 582710 582752 42 0.0
Decreases (2 builds for linux)
platform target config section 585cdcb caf19ce change % change
linux chip-tool-ipv6only arm64 (read/write) 325985 325969 -16 -0.0
.got 57040 57032 -8 -0.0
thermostat-no-ble arm64 (read/write) 145105 145089 -16 -0.0
.got 4008 4000 -8 -0.2
Full report (14 builds for efr32, k32w, linux, p6, qpg, telink)
platform target config section 585cdcb caf19ce change % change
efr32 lighting-app BRD4161A (read only) 828876 829228 352 0.0
(read/write) 126996 126996 0 0.0
.bss 125120 125120 0 0.0
.data 1876 1876 0 0.0
.text 828868 829220 352 0.0
BRD4161A+rpc (read only) 816072 816872 800 0.1
(read/write) 143656 143656 0 0.0
.bss 141680 141680 0 0.0
.data 1976 1976 0 0.0
.text 816064 816864 800 0.1
window-app BRD4161A (read only) 802324 802676 352 0.0
(read/write) 125936 125936 0 0.0
.bss 124104 124104 0 0.0
.data 1832 1832 0 0.0
.text 802316 802668 352 0.0
k32w light k32w061+release (read/write) 655308 655324 16 0.0
.bss 76776 76776 0 0.0
.data 1848 1848 0 0.0
.text 570884 570900 16 0.0
lock k32w061+release (read/write) 659584 659600 16 0.0
.bss 77072 77072 0 0.0
.data 1868 1868 0 0.0
.text 574844 574860 16 0.0
linux chip-tool-ipv6only arm64 (read only) 7039468 7039740 272 0.0
(read/write) 325985 325969 -16 -0.0
.bss 54865 54865 0 0.0
.data 1096 1096 0 0.0
.data.rel.ro 209296 209296 0 0.0
.dynamic 560 560 0 0.0
.got 57040 57032 -8 -0.0
.init 24 24 0 0.0
.init_array 168 168 0 0.0
.rodata 384404 384404 0 0.0
.text 5961492 5961796 304 0.0
thermostat-no-ble arm64 (read only) 2033468 2033788 320 0.0
(read/write) 145105 145089 -16 -0.0
.bss 64657 64657 0 0.0
.data 880 880 0 0.0
.data.rel.ro 72624 72624 0 0.0
.dynamic 560 560 0 0.0
.got 4008 4000 -8 -0.2
.init 24 24 0 0.0
.init_array 296 296 0 0.0
.rodata 128988 128988 0 0.0
.text 1690800 1691152 352 0.0
p6 all-clusters-app default (read/write) 2401624 2401640 16 0.0
.bss 116804 116804 0 0.0
.data 2592 2592 0 0.0
.text 1359888 1359904 16 0.0
light-app default (read/write) 2323648 2323664 16 0.0
.bss 105672 105672 0 0.0
.data 2384 2384 0 0.0
.text 1281912 1281928 16 0.0
lock-app default (read/write) 2295872 2295888 16 0.0
.bss 104552 104552 0 0.0
.data 2336 2336 0 0.0
.text 1254136 1254152 16 0.0
qpg lighting-app qpg6105+debug (read only) 533160 533176 16 0.0
(read/write) 146936 146936 0 0.0
.bss 86624 86624 0 0.0
.data 1004 1004 0 0.0
.text 527840 527856 16 0.0
lock-app qpg6105+debug (read only) 504936 504952 16 0.0
(read/write) 146940 146940 0 0.0
.bss 85760 85760 0 0.0
.data 952 952 0 0.0
.text 499616 499632 16 0.0
persistent-storage-app qpg6105+debug (read only) 106448 106448 0 0.0
(read/write) 146938 146938 0 0.0
.bss 36146 36146 0 0.0
.data 288 288 0 0.0
.text 101128 101128 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 834466 834506 40 0.0
bss 86924 86924 0 0.0
noinit 37160 37160 0 0.0
text 582710 582752 42 0.0

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

PR #13357: Size comparison from c25c4b3 to 87990b6

Increases (23 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section c25c4b3 87990b6 change % change
efr32 lighting-app BRD4161A (read only) 829196 829228 32 0.0
.text 829188 829220 32 0.0
BRD4161A+rpc (read only) 816840 816872 32 0.0
.text 816832 816864 32 0.0
window-app BRD4161A (read only) 802660 802676 16 0.0
.text 802652 802668 16 0.0
esp32 all-clusters-app c3devkit (read only) 891834 891882 48 0.0
.flash.text 891834 891882 48 0.0
m5stack (read only) 951779 951835 56 0.0
.flash.text 946395 946451 56 0.0
k32w light k32w061+release (read/write) 655308 655324 16 0.0
.text 570884 570900 16 0.0
lock k32w061+release (read/write) 659584 659600 16 0.0
.text 574844 574860 16 0.0
linux chip-tool-ipv6only arm64 (read only) 7039660 7039740 80 0.0
.text 5961684 5961796 112 0.0
thermostat-no-ble arm64 (read only) 2033708 2033788 80 0.0
.text 1691040 1691152 112 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read/write) 2348496 2348560 64 0.0
.text 1311072 1311136 64 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 937083 937099 16 0.0
text 633292 633308 16 0.0
nrf52840dk_nrf52840+rpc (read/write) 923479 923495 16 0.0
text 628604 628620 16 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 848062 848078 16 0.0
text 550228 550244 16 0.0
lock-app nrf52840dk_nrf52840 (read/write) 909227 909243 16 0.0
text 611160 611176 16 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 820386 820402 16 0.0
text 528132 528148 16 0.0
pump-app nrf52840dk_nrf52840 (read/write) 910491 910507 16 0.0
text 612372 612388 16 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 907307 907323 16 0.0
text 609908 609924 16 0.0
p6 all-clusters-app default (read/write) 2401624 2401640 16 0.0
.text 1359888 1359904 16 0.0
light-app default (read/write) 2323648 2323664 16 0.0
.text 1281912 1281928 16 0.0
lock-app default (read/write) 2295872 2295888 16 0.0
.text 1254136 1254152 16 0.0
qpg lighting-app qpg6105+debug (read only) 533160 533176 16 0.0
.text 527840 527856 16 0.0
lock-app qpg6105+debug (read only) 504936 504952 16 0.0
.text 499616 499632 16 0.0
telink lighting-app tlsr9518adk80d (read/write) 834466 834506 40 0.0
text 582710 582752 42 0.0
Decreases (2 builds for linux)
platform target config section c25c4b3 87990b6 change % change
linux chip-tool-ipv6only arm64 (read/write) 325985 325969 -16 -0.0
.got 57040 57032 -8 -0.0
thermostat-no-ble arm64 (read/write) 145105 145089 -16 -0.0
.got 4008 4000 -8 -0.2
Full report (31 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section c25c4b3 87990b6 change % change
efr32 lighting-app BRD4161A (read only) 829196 829228 32 0.0
(read/write) 126996 126996 0 0.0
.bss 125120 125120 0 0.0
.data 1876 1876 0 0.0
.text 829188 829220 32 0.0
BRD4161A+rpc (read only) 816840 816872 32 0.0
(read/write) 143656 143656 0 0.0
.bss 141680 141680 0 0.0
.data 1976 1976 0 0.0
.text 816832 816864 32 0.0
window-app BRD4161A (read only) 802660 802676 16 0.0
(read/write) 125936 125936 0 0.0
.bss 124104 124104 0 0.0
.data 1832 1832 0 0.0
.text 802652 802668 16 0.0
esp32 all-clusters-app c3devkit (read only) 891834 891882 48 0.0
(read/write) 1314010 1314010 0 0.0
.dram0.bss 69464 69464 0 0.0
.dram0.data 14236 14236 0 0.0
.flash.rodata 177248 177248 0 0.0
.flash.text 891834 891882 48 0.0
.iram0.text 62254 62254 0 0.0
m5stack (read only) 951779 951835 56 0.0
(read/write) 445592 445592 0 0.0
.dram0.bss 73960 73960 0 0.0
.dram0.data 34064 34064 0 0.0
.flash.rodata 206560 206560 0 0.0
.flash.text 946395 946451 56 0.0
.iram0.text 122671 122671 0 0.0
k32w light k32w061+release (read/write) 655308 655324 16 0.0
.bss 76776 76776 0 0.0
.data 1848 1848 0 0.0
.text 570884 570900 16 0.0
lock k32w061+release (read/write) 659584 659600 16 0.0
.bss 77072 77072 0 0.0
.data 1868 1868 0 0.0
.text 574844 574860 16 0.0
linux chip-tool-ipv6only arm64 (read only) 7039660 7039740 80 0.0
(read/write) 325985 325969 -16 -0.0
.bss 54865 54865 0 0.0
.data 1096 1096 0 0.0
.data.rel.ro 209296 209296 0 0.0
.dynamic 560 560 0 0.0
.got 57040 57032 -8 -0.0
.init 24 24 0 0.0
.init_array 168 168 0 0.0
.rodata 384404 384404 0 0.0
.text 5961684 5961796 112 0.0
thermostat-no-ble arm64 (read only) 2033708 2033788 80 0.0
(read/write) 145105 145089 -16 -0.0
.bss 64657 64657 0 0.0
.data 880 880 0 0.0
.data.rel.ro 72624 72624 0 0.0
.dynamic 560 560 0 0.0
.got 4008 4000 -8 -0.2
.init 24 24 0 0.0
.init_array 296 296 0 0.0
.rodata 128988 128988 0 0.0
.text 1691040 1691152 112 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2348496 2348560 64 0.0
.bss 188724 188724 0 0.0
.data 5312 5312 0 0.0
.text 1311072 1311136 64 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2330688 2330688 0 0.0
.bss 180544 180544 0 0.0
.data 5552 5552 0 0.0
.text 1293288 1293288 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2303840 2303840 0 0.0
.bss 179592 179592 0 0.0
.data 5544 5544 0 0.0
.text 1266440 1266440 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1140008 1140008 0 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103392 103392 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2054256 2054256 0 0.0
.bss 157060 157060 0 0.0
.data 4864 4864 0 0.0
.text 1016856 1016856 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 937083 937099 16 0.0
bss 118112 118112 0 0.0
rodata 108120 108120 0 0.0
text 633292 633308 16 0.0
nrf52840dk_nrf52840+rpc (read/write) 923479 923495 16 0.0
bss 115156 115156 0 0.0
rodata 101548 101548 0 0.0
text 628604 628620 16 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 848062 848078 16 0.0
bss 116004 116004 0 0.0
rodata 101296 101296 0 0.0
text 550228 550244 16 0.0
lock-app nrf52840dk_nrf52840 (read/write) 909227 909243 16 0.0
bss 117300 117300 0 0.0
rodata 103392 103392 0 0.0
text 611160 611176 16 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 820386 820402 16 0.0
bss 115220 115220 0 0.0
rodata 96620 96620 0 0.0
text 528132 528148 16 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 542351 542351 0 0.0
bss 52588 52588 0 0.0
rodata 50668 50668 0 0.0
text 376892 376892 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 910491 910507 16 0.0
bss 117060 117060 0 0.0
rodata 103608 103608 0 0.0
text 612372 612388 16 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 907307 907323 16 0.0
bss 117088 117088 0 0.0
rodata 102864 102864 0 0.0
text 609908 609924 16 0.0
shell nrf52840dk_nrf52840 (read/write) 797919 797919 0 0.0
bss 109768 109768 0 0.0
rodata 78148 78148 0 0.0
text 533496 533496 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 710734 710734 0 0.0
bss 107656 107656 0 0.0
rodata 72448 72448 0 0.0
text 451172 451172 0 0.0
p6 all-clusters-app default (read/write) 2401624 2401640 16 0.0
.bss 116804 116804 0 0.0
.data 2592 2592 0 0.0
.text 1359888 1359904 16 0.0
light-app default (read/write) 2323648 2323664 16 0.0
.bss 105672 105672 0 0.0
.data 2384 2384 0 0.0
.text 1281912 1281928 16 0.0
lock-app default (read/write) 2295872 2295888 16 0.0
.bss 104552 104552 0 0.0
.data 2336 2336 0 0.0
.text 1254136 1254152 16 0.0
qpg lighting-app qpg6105+debug (read only) 533160 533176 16 0.0
(read/write) 146936 146936 0 0.0
.bss 86624 86624 0 0.0
.data 1004 1004 0 0.0
.text 527840 527856 16 0.0
lock-app qpg6105+debug (read only) 504936 504952 16 0.0
(read/write) 146940 146940 0 0.0
.bss 85760 85760 0 0.0
.data 952 952 0 0.0
.text 499616 499632 16 0.0
persistent-storage-app qpg6105+debug (read only) 106448 106448 0 0.0
(read/write) 146938 146938 0 0.0
.bss 36146 36146 0 0.0
.data 288 288 0 0.0
.text 101128 101128 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 834466 834506 40 0.0
bss 86924 86924 0 0.0
noinit 37160 37160 0 0.0
text 582710 582752 42 0.0

@msandstedt
Copy link
Contributor Author

Approving, but let's do a followup to consolidate the must-be-done-just-so code.

Helpers were added to CASESession and PASESession with ba75737. But followup filed here: #13383.

@msandstedt msandstedt merged commit b53521c into project-chip:master Jan 7, 2022
msandstedt added a commit to msandstedt/connectedhomeip that referenced this pull request Jan 7, 2022
msandstedt added a commit to msandstedt/connectedhomeip that referenced this pull request Jan 8, 2022
msandstedt added a commit to msandstedt/connectedhomeip that referenced this pull request Jan 27, 2022
msandstedt added a commit to msandstedt/connectedhomeip that referenced this pull request Feb 3, 2022
step0035 pushed a commit to hank820/connectedhomeip that referenced this pull request Feb 8, 2022
The fix in project-chip#12794 means that the CASESession and PASESession objects do
not need to persist for ExchangeMessageDispatch::SendMessage to succeed
at the final ACK of session establishment.  Instead, SendMessage uses the
SessionEstablishmentExchangeDispatch global singleton.

This means we can address 13146 such that CASESession and PASESession may
actually be freed or reused when completion callbacks fire.  This will
only work, however, if these objects clear themselves as delegates for
their exchange contexts when discarding references to these.  This
commit does so.

This commit also reorders all calls to mDelegate->OnSessionEstablished and
mDelegate->OnSessionEstablishmentError to occur last in any given method
in case mDelegate frees or reuses the CASESession or PASESession objects
on execution of these completion callbacks.

With this, we can remove the code in the OperationalDeviceProxy that
defers release of the CASESession object until after an iteration of the
event loop.  Now when OnSessionEstablished fires, the CASESession can be
reused or discarded immediately.
@msandstedt msandstedt deleted the bugfix/13146 branch March 31, 2022 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improper exchange context lifetime handling in PASESession.cpp and CASESession.cpp
3 participants