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

Fix leak in MTRBaseDevice tests. #33275

Merged
merged 1 commit into from
May 3, 2024

Conversation

bzbarsky-apple
Copy link
Contributor

Our test code in deregisterReportHandlersWithQueue would directly delete the ReadClient, but that never called OnDone, and hence never deleted the BufferedReadClientCallback that we had also allocated.

The fix is to put all the things we need to deallocate in the MTRReadClientContainer and consistently use it to clean those things up, including on all the various failure paths we have.

Removes the CauseReadClientFailure function which did not in fact cause a failure, and instead just has the relevant test trigger a subscription drop.

Our test code in deregisterReportHandlersWithQueue would directly delete the
ReadClient, but that never called OnDone, and hence never deleted the
BufferedReadClientCallback<MTRDataValueDictionaryDecodableType> that we had also
allocated.

The fix is to put all the things we need to deallocate in the
MTRReadClientContainer and consistently use it to clean those things up,
including on all the various failure paths we have.

Removes the CauseReadClientFailure function which did not in fact cause a
failure, and instead just has the relevant test trigger a subscription drop.
Copy link

github-actions bot commented May 2, 2024

PR #33275: Size comparison from 3fa70cf to 4dedcf4

Decreases (2 builds for efr32)
platform target config section 3fa70cf 4dedcf4 change % change
efr32 lock-app BRD4338a (read/write) 962060 962052 -8 -0.0
.text 700184 700176 -8 -0.0
window-app BRD4187C (read/write) 1137512 1137504 -8 -0.0
.text 969556 969548 -8 -0.0
Full report (71 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, mbed, nrfconnect, nxp, psoc6, qpg, stm32, telink)
platform target config section 3fa70cf 4dedcf4 change % change
bl602 lighting-app bl602 (read/write) 1444358 1444358 0 0.0
.bss 85744 85744 0 0.0
.data 9512 9512 0 0.0
.rodata 159200 159200 0 0.0
.text 1109236 1109236 0 0.0
bl602+mfd (read/write) 1458782 1458782 0 0.0
.bss 85912 85912 0 0.0
.data 9488 9488 0 0.0
.rodata 158160 158160 0 0.0
.text 1124554 1124554 0 0.0
bl602+rpc (read/write) 1492006 1492006 0 0.0
.bss 93784 93784 0 0.0
.data 9888 9888 0 0.0
.rodata 166768 166768 0 0.0
.text 1140882 1140882 0 0.0
bl702 lighting-app bl702 (read only) 3478 3478 0 0.0
(read/write) 1210043 1210043 0 0.0
.bss 11185 11185 0 0.0
.data 3704 3704 0 0.0
.rodata 108796 108796 0 0.0
.text 979380 979380 0 0.0
bl702+mfd (read only) 3478 3478 0 0.0
(read/write) 1220883 1220883 0 0.0
.bss 11361 11361 0 0.0
.data 3688 3688 0 0.0
.rodata 107736 107736 0 0.0
.text 991134 991134 0 0.0
bl702+rpc (read only) 3478 3478 0 0.0
(read/write) 1301531 1301531 0 0.0
.bss 19669 19669 0 0.0
.data 4248 4248 0 0.0
.rodata 124168 124168 0 0.0
.text 1054088 1054088 0 0.0
bl706-eth (read/write) 1026465 1026465 0 0.0
.bss 23760 23760 0 0.0
.data 3256 3256 0 0.0
.rodata 101892 101892 0 0.0
.text 769234 769234 0 0.0
bl706-wifi (read/write) 1261914 1261914 0 0.0
.bss 10645 10645 0 0.0
.data 3704 3704 0 0.0
.rodata 122884 122884 0 0.0
.text 1001908 1001908 0 0.0
bl702l lighting-app bl702l (read/write) 1179896 1179896 0 0.0
.bss 16396 16396 0 0.0
.data 5072 5072 0 0.0
.rodata 102800 102800 0 0.0
.text 972234 972234 0 0.0
bl702l+mfd (read only) 512 512 0 0.0
(read/write) 1190780 1190780 0 0.0
.bss 16572 16572 0 0.0
.data 5048 5048 0 0.0
.rodata 101740 101740 0 0.0
.text 984556 984556 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 (read only) 798348 798348 0 0.0
(read/write) 177612 177612 0 0.0
.bss 99556 99556 0 0.0
.data 3588 3588 0 0.0
.rodata 84924 84924 0 0.0
.text 713160 713160 0 0.0
lock-ftd LP_EM_CC1354P10_6 (read only) 813640 813640 0 0.0
(read/write) 188100 188100 0 0.0
.bss 110044 110044 0 0.0
.data 3588 3588 0 0.0
.rodata 78552 78552 0 0.0
.text 734824 734824 0 0.0
lock-mtd LP_EM_CC1354P10_6 (read only) 802924 802924 0 0.0
(read/write) 182220 182220 0 0.0
.bss 104164 104164 0 0.0
.data 3588 3588 0 0.0
.rodata 105828 105828 0 0.0
.text 696832 696832 0 0.0
pump-app LP_EM_CC1354P10_6 (read only) 755204 755204 0 0.0
(read/write) 176588 176588 0 0.0
.bss 98296 98296 0 0.0
.data 3580 3580 0 0.0
.rodata 80580 80580 0 0.0
.text 674360 674360 0 0.0
pump-controller-app LP_EM_CC1354P10_6 (read only) 740892 740892 0 0.0
(read/write) 176796 176796 0 0.0
.bss 98520 98520 0 0.0
.data 3572 3572 0 0.0
.rodata 76364 76364 0 0.0
.text 664264 664264 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL (read only) 605430 605430 0 0.0
(read/write) 209572 209572 0 0.0
.bss 202796 202796 0 0.0
.data 1652 1652 0 0.0
.rodata 89574 89574 0 0.0
.text 513732 513732 0 0.0
lock CC3235SF_LAUNCHXL (read only) 651318 651318 0 0.0
(read/write) 209836 209836 0 0.0
.bss 203200 203200 0 0.0
.data 1516 1516 0 0.0
.rodata 110334 110334 0 0.0
.text 538864 538864 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 571543 571543 0 0.0
.app_xip_area 461429 461429 0 0.0
.bss 64932 64932 0 0.0
.data 760 760 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 553639 553639 0 0.0
.app_xip_area 438853 438853 0 0.0
.bss 69596 69596 0 0.0
.data 768 768 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 574271 574271 0 0.0
.app_xip_area 465653 465653 0 0.0
.bss 63476 63476 0 0.0
.data 720 720 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
switch cyw930739m2evb_01 (read/write) 566847 566847 0 0.0
.app_xip_area 455045 455045 0 0.0
.bss 66580 66580 0 0.0
.data 800 800 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4187C (read/write) 1070788 1070788 0 0.0
.bss 180008 180008 0 0.0
.data 3432 3432 0 0.0
.text 887328 887328 0 0.0
lock-app BRD4338a (read/write) 962060 962052 -8 -0.0
.bss 213064 213064 0 0.0
.data 29448 29448 0 0.0
.text 700184 700176 -8 -0.0
window-app BRD4187C (read/write) 1137512 1137504 -8 -0.0
.bss 164600 164600 0 0.0
.data 3336 3336 0 0.0
.text 969556 969548 -8 -0.0
esp32 all-clusters-app c3devkit (read only) 1215006 1215006 0 0.0
(read/write) 1751296 1751296 0 0.0
.dram0.bss 74592 74592 0 0.0
.dram0.data 13652 13652 0 0.0
.flash.rodata 253520 253520 0 0.0
.flash.text 1215006 1215006 0 0.0
.iram0.text 75570 75570 0 0.0
m5stack (read only) 1256683 1256683 0 0.0
(read/write) 537708 537708 0 0.0
.dram0.bss 81344 81344 0 0.0
.dram0.data 35196 35196 0 0.0
.flash.rodata 285248 285248 0 0.0
.flash.text 1250519 1250519 0 0.0
.iram0.text 125403 125403 0 0.0
linux air-purifier-app debug (read only) 2713485 2713485 0 0.0
(read/write) 132432 132432 0 0.0
.bss 47720 47720 0 0.0
.data 2272 2272 0 0.0
.data.rel.ro 76440 76440 0 0.0
.dynamic 608 608 0 0.0
.got 4576 4576 0 0.0
.init 27 27 0 0.0
.init_array 800 800 0 0.0
.rodata 186544 186544 0 0.0
.text 2344005 2344005 0 0.0
all-clusters-app debug (read only) 6026057 6026057 0 0.0
(read/write) 483976 483976 0 0.0
.bss 136000 136000 0 0.0
.data 4560 4560 0 0.0
.data.rel.ro 335960 335960 0 0.0
.dynamic 624 624 0 0.0
.got 5344 5344 0 0.0
.init 27 27 0 0.0
.init_array 1440 1440 0 0.0
.rodata 353264 353264 0 0.0
.text 5234147 5234147 0 0.0
all-clusters-minimal-app debug (read only) 5309593 5309593 0 0.0
(read/write) 239928 239928 0 0.0
.bss 128864 128864 0 0.0
.data 4464 4464 0 0.0
.data.rel.ro 99496 99496 0 0.0
.dynamic 624 624 0 0.0
.got 5264 5264 0 0.0
.init 27 27 0 0.0
.init_array 1168 1168 0 0.0
.rodata 292170 292170 0 0.0
.text 4777587 4777587 0 0.0
bridge-app debug (read only) 4700201 4700201 0 0.0
(read/write) 220840 220840 0 0.0
.bss 119392 119392 0 0.0
.data 6240 6240 0 0.0
.data.rel.ro 88464 88464 0 0.0
.dynamic 624 624 0 0.0
.got 5232 5232 0 0.0
.init 27 27 0 0.0
.init_array 864 864 0 0.0
.rodata 232618 232618 0 0.0
.text 4242163 4242163 0 0.0
chip-tool debug (read only) 12144937 12144937 0 0.0
(read/write) 524288 524288 0 0.0
.bss 95032 95032 0 0.0
.data 5122 5122 0 0.0
.data.rel.ro 416904 416904 0 0.0
.dynamic 624 624 0 0.0
.got 5736 5736 0 0.0
.init 27 27 0 0.0
.init_array 832 832 0 0.0
.rodata 453081 453081 0 0.0
.text 10981219 10981219 0 0.0
chip-tool-ipv6only arm64 (read only) 11473348 11473348 0 0.0
(read/write) 591856 591856 0 0.0
.bss 104008 104008 0 0.0
.data 4520 4520 0 0.0
.data.rel.ro 457000 457000 0 0.0
.dynamic 512 512 0 0.0
.got 17232 17232 0 0.0
.init 24 24 0 0.0
.init_array 280 280 0 0.0
.rodata 357476 357476 0 0.0
.text 10231256 10231256 0 0.0
lighting-app debug+rpc+ui (read only) 5623793 5623793 0 0.0
(read/write) 229640 229640 0 0.0
.bss 120336 120336 0 0.0
.data 4896 4896 0 0.0
.data.rel.ro 96880 96880 0 0.0
.dynamic 672 672 0 0.0
.got 5864 5864 0 0.0
.init 27 27 0 0.0
.init_array 976 976 0 0.0
.rodata 356468 356468 0 0.0
.text 5015475 5015475 0 0.0
lock-app debug (read only) 4767241 4767241 0 0.0
(read/write) 208032 208032 0 0.0
.bss 114664 114664 0 0.0
.data 4192 4192 0 0.0
.data.rel.ro 82472 82472 0 0.0
.dynamic 624 624 0 0.0
.got 5184 5184 0 0.0
.init 27 27 0 0.0
.init_array 880 880 0 0.0
.rodata 258538 258538 0 0.0
.text 4292355 4292355 0 0.0
ota-provider-app debug (read only) 4375145 4375145 0 0.0
(read/write) 196504 196504 0 0.0
.bss 114464 114464 0 0.0
.data 4368 4368 0 0.0
.data.rel.ro 71712 71712 0 0.0
.dynamic 624 624 0 0.0
.got 4552 4552 0 0.0
.init 27 27 0 0.0
.init_array 752 752 0 0.0
.rodata 211370 211370 0 0.0
.text 3966083 3966083 0 0.0
ota-requestor-app debug (read only) 4505849 4505849 0 0.0
(read/write) 200872 200872 0 0.0
.bss 115360 115360 0 0.0
.data 4768 4768 0 0.0
.data.rel.ro 74816 74816 0 0.0
.dynamic 624 624 0 0.0
.got 4488 4488 0 0.0
.init 27 27 0 0.0
.init_array 800 800 0 0.0
.rodata 217450 217450 0 0.0
.text 4086163 4086163 0 0.0
shell debug (read only) 2997585 2997585 0 0.0
(read/write) 159408 159408 0 0.0
.bss 63504 63504 0 0.0
.data 1424 1424 0 0.0
.data.rel.ro 88640 88640 0 0.0
.dynamic 592 592 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 1112 1112 0 0.0
.rodata 189984 189984 0 0.0
.text 2628642 2628642 0 0.0
thermostat-no-ble arm64 (read only) 4493740 4493740 0 0.0
(read/write) 248216 248216 0 0.0
.bss 122984 122984 0 0.0
.data 3408 3408 0 0.0
.data.rel.ro 105912 105912 0 0.0
.dynamic 512 512 0 0.0
.got 8960 8960 0 0.0
.init 24 24 0 0.0
.init_array 448 448 0 0.0
.rodata 161876 161876 0 0.0
.text 3990664 3990664 0 0.0
tv-app debug (read only) 5823441 5823441 0 0.0
(read/write) 355224 355224 0 0.0
.bss 245136 245136 0 0.0
.data 6560 6560 0 0.0
.data.rel.ro 96248 96248 0 0.0
.dynamic 624 624 0 0.0
.got 5464 5464 0 0.0
.init 27 27 0 0.0
.init_array 1184 1184 0 0.0
.rodata 296746 296746 0 0.0
.text 5280563 5280563 0 0.0
tv-casting-app debug (read only) 9983993 9983993 0 0.0
(read/write) 345632 345632 0 0.0
.bss 159448 159448 0 0.0
.data 3008 3008 0 0.0
.data.rel.ro 176208 176208 0 0.0
.dynamic 624 624 0 0.0
.got 5096 5096 0 0.0
.init 27 27 0 0.0
.init_array 1216 1216 0 0.0
.rodata 386840 386840 0 0.0
.text 9126307 9126307 0 0.0
mbed lock-app-release cy8cproto_062_4343w (read only) 6224 6224 0 0.0
(read/write) 2536744 2536744 0 0.0
.bss 220768 220768 0 0.0
.data 5216 5216 0 0.0
.text 1499428 1499428 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1060320 1060320 0 0.0
bss 139123 139123 0 0.0
rodata 101552 101552 0 0.0
text 772420 772420 0 0.0
nrf7002dk_nrf5340_cpuapp (read only) 4 4 0 0.0
(read/write) 1237552 1237552 0 0.0
bss 137419 137419 0 0.0
rodata 151384 151384 0 0.0
text 798712 798712 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read only) 4 4 0 0.0
(read/write) 1008096 1008096 0 0.0
bss 138029 138029 0 0.0
rodata 88808 88808 0 0.0
text 733972 733972 0 0.0
nxp contact k32w0+release (read only) 576508 576508 0 0.0
(read/write) 83164 83164 0 0.0
.bss 67880 67880 0 0.0
.data 2188 2188 0 0.0
.text 575972 575972 0 0.0
k32w1+release (read only) 1024 1024 0 0.0
(read/write) 703996 703996 0 0.0
.bss 71224 71224 0 0.0
.data 2864 2864 0 0.0
.text 590528 590528 0 0.0
light k32w0+release (read only) 610568 610568 0 0.0
(read/write) 82624 82624 0 0.0
.bss 67320 67320 0 0.0
.data 2208 2208 0 0.0
.text 610032 610032 0 0.0
k32w1+release (read only) 1024 1024 0 0.0
(read/write) 795840 795840 0 0.0
.bss 80760 80760 0 0.0
.data 2064 2064 0 0.0
.text 673648 673648 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 (read only) 826288 826288 0 0.0
(read/write) 1826836 1826836 0 0.0
.bss 204308 204308 0 0.0
.data 2744 2744 0 0.0
.text 1611396 1611396 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 (read only) 829384 829384 0 0.0
(read/write) 1748108 1748108 0 0.0
.bss 201236 201236 0 0.0
.data 2720 2720 0 0.0
.text 1535764 1535764 0 0.0
light cy8ckit_062s2_43012 (read only) 836104 836104 0 0.0
(read/write) 1666572 1666572 0 0.0
.bss 194700 194700 0 0.0
.data 2536 2536 0 0.0
.text 1460948 1460948 0 0.0
lock cy8ckit_062s2_43012 (read only) 809040 809040 0 0.0
(read/write) 1695220 1695220 0 0.0
.bss 221780 221780 0 0.0
.data 2520 2520 0 0.0
.text 1462532 1462532 0 0.0
qpg lighting-app qpg6105+debug (read/write) 1134156 1134156 0 0.0
.bss 102644 102644 0 0.0
.data 856 856 0 0.0
.text 646536 646536 0 0.0
lock-app qpg6105+debug (read/write) 1094004 1094004 0 0.0
.bss 97316 97316 0 0.0
.data 860 860 0 0.0
.text 606388 606388 0 0.0
stm32 light STM32WB5MM-DK (read/write) 605809 605809 0 0.0
.bss 128492 128492 0 0.0
.data 688 688 0 0.0
.rodata 80516 80516 0 0.0
.text 386368 386368 0 0.0
telink air-quality-sensor-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 834058 834058 0 0.0
bss 49876 49876 0 0.0
text 624724 624724 0 0.0
all-clusters-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 1096448 1096448 0 0.0
bss 101544 101544 0 0.0
text 797442 797442 0 0.0
all-clusters-minimal-app tlsr9528a (read only) 47960 47960 0 0.0
(read/write) 1058916 1058916 0 0.0
bss 110040 110040 0 0.0
text 772762 772762 0 0.0
bridge-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 914556 914556 0 0.0
bss 92796 92796 0 0.0
text 656364 656364 0 0.0
contact-sensor-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 836410 836410 0 0.0
bss 49920 49920 0 0.0
text 627144 627144 0 0.0
light-switch-app-ota-shell-factory-data tlsr9528a (read only) 51584 51584 0 0.0
(read/write) 937232 937232 0 0.0
bss 77532 77532 0 0.0
text 703798 703798 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d (read only) 29122 29122 0 0.0
(read/write) 1090948 1090948 0 0.0
bss 99888 99888 0 0.0
text 794350 794350 0 0.0
lock-app-dfu tlsr9528a (read only) 51584 51584 0 0.0
(read/write) 911528 911528 0 0.0
bss 69200 69200 0 0.0
text 660542 660542 0 0.0
ota-requestor-app tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 933360 933360 0 0.0
bss 92500 92500 0 0.0
text 675350 675350 0 0.0
pump-app tlsr9258a (read only) 52490 52490 0 0.0
(read/write) 833976 833976 0 0.0
bss 58164 58164 0 0.0
text 624150 624150 0 0.0
pump-controller-app tlsr9518adk80d (read only) 31872 31872 0 0.0
(read/write) 800088 800088 0 0.0
bss 56092 56092 0 0.0
text 599052 599052 0 0.0
shell tlsr9518adk80d (read only) 29042 29042 0 0.0
(read/write) 676056 676056 0 0.0
bss 73412 73412 0 0.0
text 461740 461740 0 0.0
smoke_co_alarm-app tlsr9528a_retention (read only) 51774 51774 0 0.0
(read/write) 844278 844278 0 0.0
bss 51548 51548 0 0.0
text 633812 633812 0 0.0
temperature-measurement-app-mars-ota tlsr9518adk80d (read only) 32220 32220 0 0.0
(read/write) 858929 858929 0 0.0
bss 59716 59716 0 0.0
text 642592 642592 0 0.0
thermostat tlsr9518adk80d (read only) 31872 31872 0 0.0
(read/write) 825652 825652 0 0.0
bss 56424 56424 0 0.0
text 618614 618614 0 0.0
window-covering tlsr9258a (read only) 52490 52490 0 0.0
(read/write) 838672 838672 0 0.0
bss 58380 58380 0 0.0
text 626418 626418 0 0.0

@bzbarsky-apple
Copy link
Contributor Author

Fast-tracking platform-specific change with platform owner review.

@mergify mergify bot merged commit 0afc132 into project-chip:master May 3, 2024
66 checks passed
@bzbarsky-apple bzbarsky-apple deleted the fix-MTRBaseDevice-leak branch May 3, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants