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 FabricTable memory leak in DeviceControllerSystemState #14658

Merged

Conversation

kianooshkarami
Copy link
Contributor

Problem

What is being fixed?
Fix FabricTable memory leak in DeviceControllerSystemState

Change overview

FabricTable is instantiated in DeviceControllerFactory::InitSystemState
as shown below

    stateParams.fabricTable           = chip::Platform::New<FabricTable>();

stateParams (type: DeviceControllerSystemStateParams) is then passed
onto DeviceControllerFactory::mSystemState (type: DeviceControllerSystemState), where stateParams.fabricTable is now stored in mSystemState.mFabrics.

We need to ensure that the original memory allocated in the initial step
is now freed in DeviceControllerSystemState::Shutdown()

Testing

How was this tested? (at least one bullet point required)
Answer: This was validated through memory sanitizer

  • If unit tests were added, how do they cover this issue?
    ** No Unit test check for similar memory leaks.

FabricTable is instantiated in DeviceControllerFactory::InitSystemState
as shown below

```
    stateParams.fabricTable           = chip::Platform::New<FabricTable>();
```

stateParams (type: DeviceControllerSystemStateParams) is then passed
onto DeviceControllerFactory::mSystemState (type: DeviceControllerSystemState), where stateParams.fabricTable is now stored in mSystemState.mFabrics.

We need to ensure that the original memory allocated in the initial step
is now freed in DeviceControllerSystemState::Shutdown()
@github-actions
Copy link

github-actions bot commented Feb 1, 2022

PR #14658: Size comparison from cb9b046 to f7990f1

Increases (3 builds for linux)
platform target config section cb9b046 f7990f1 change % change
linux chip-tool debug (read only) 7085949 7086045 96 0.0
.text 6315269 6315365 96 0.0
chip-tool-ipv6only arm64 (read only) 7036516 7036596 80 0.0
.text 6049796 6049876 80 0.0
tv-app debug (read only) 2408921 2409017 96 0.0
.text 2046498 2046594 96 0.0
Full report (43 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section cb9b046 f7990f1 change % change
cyw30739 light cyw930739m2evb_01 (read/write) 577150 577150 0 0.0
.app_xip_area 484356 484356 0 0.0
.bss 75540 75540 0 0.0
.data 596 596 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
lock cyw930739m2evb_01 (read/write) 535146 535146 0 0.0
.app_xip_area 443920 443920 0 0.0
.bss 74012 74012 0 0.0
.data 560 560 0 0.0
.rodata 0 0 0 0.0
.text 0 0 0 0.0
ota-requestor cyw930739m2evb_01 (read/write) 559890 559890 0 0.0
.app_xip_area 459360 459360 0 0.0
.bss 82988 82988 0 0.0
.data 504 504 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 843616 843616 0 0.0
(read/write) 125072 125072 0 0.0
.bss 123176 123176 0 0.0
.data 1896 1896 0 0.0
.text 843608 843608 0 0.0
BRD4161A+rpc (read only) 830984 830984 0 0.0
(read/write) 141736 141736 0 0.0
.bss 139736 139736 0 0.0
.data 1996 1996 0 0.0
.text 830976 830976 0 0.0
window-app BRD4161A (read only) 816164 816164 0 0.0
(read/write) 123704 123704 0 0.0
.bss 121852 121852 0 0.0
.data 1852 1852 0 0.0
.text 816156 816156 0 0.0
esp32 all-clusters-app c3devkit (read only) 934322 934322 0 0.0
(read/write) 1399890 1399890 0 0.0
.dram0.bss 70344 70344 0 0.0
.dram0.data 14268 14268 0 0.0
.flash.rodata 196376 196376 0 0.0
.flash.text 934322 934322 0 0.0
.iram0.text 62056 62056 0 0.0
m5stack (read only) 982339 982339 0 0.0
(read/write) 464236 464236 0 0.0
.dram0.bss 75096 75096 0 0.0
.dram0.data 34024 34024 0 0.0
.flash.rodata 222988 222988 0 0.0
.flash.text 976955 976955 0 0.0
.iram0.text 123399 123399 0 0.0
k32w light k32w061+release (read/write) 661876 661876 0 0.0
.bss 75228 75228 0 0.0
.data 1856 1856 0 0.0
.text 578992 578992 0 0.0
lock k32w061+release (read/write) 662888 662888 0 0.0
.bss 75548 75548 0 0.0
.data 1896 1896 0 0.0
.text 579644 579644 0 0.0
linux all-clusters-app debug (read only) 2301529 2301529 0 0.0
(read/write) 147168 147168 0 0.0
.bss 63072 63072 0 0.0
.data 1200 1200 0 0.0
.data.rel.ro 77224 77224 0 0.0
.dynamic 592 592 0 0.0
.got 4128 4128 0 0.0
.init 27 27 0 0.0
.init_array 920 920 0 0.0
.rodata 203813 203813 0 0.0
.text 1936914 1936914 0 0.0
bridge-app debug+rpc (read only) 1633069 1633069 0 0.0
(read/write) 87912 87912 0 0.0
.bss 43808 43808 0 0.0
.data 1794 1794 0 0.0
.data.rel.ro 37152 37152 0 0.0
.dynamic 592 592 0 0.0
.got 3968 3968 0 0.0
.init 27 27 0 0.0
.init_array 544 544 0 0.0
.rodata 138196 138196 0 0.0
.text 1379925 1379925 0 0.0
chip-tool debug (read only) 7085949 7086045 96 0.0
(read/write) 187304 187304 0 0.0
.bss 36264 36264 0 0.0
.data 1088 1088 0 0.0
.data.rel.ro 143968 143968 0 0.0
.dynamic 608 608 0 0.0
.got 4760 4760 0 0.0
.init 27 27 0 0.0
.init_array 600 600 0 0.0
.rodata 404629 404629 0 0.0
.text 6315269 6315365 96 0.0
chip-tool-ipv6only arm64 (read only) 7036516 7036596 80 0.0
(read/write) 289857 289857 0 0.0
.bss 54593 54593 0 0.0
.data 1128 1128 0 0.0
.data.rel.ro 185152 185152 0 0.0
.dynamic 560 560 0 0.0
.got 45200 45200 0 0.0
.init 24 24 0 0.0
.init_array 184 184 0 0.0
.rodata 387836 387836 0 0.0
.text 6049796 6049876 80 0.0
door-lock-app debug (read only) 1854057 1854057 0 0.0
(read/write) 117824 117824 0 0.0
.bss 49888 49888 0 0.0
.data 962 962 0 0.0
.data.rel.ro 61552 61552 0 0.0
.dynamic 592 592 0 0.0
.got 4104 4104 0 0.0
.init 27 27 0 0.0
.init_array 664 664 0 0.0
.rodata 171516 171516 0 0.0
.text 1534642 1534642 0 0.0
lighting-app debug+rpc (read only) 1954785 1954785 0 0.0
(read/write) 122784 122784 0 0.0
.bss 50840 50840 0 0.0
.data 1392 1392 0 0.0
.data.rel.ro 65056 65056 0 0.0
.dynamic 608 608 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 704 704 0 0.0
.rodata 161265 161265 0 0.0
.text 1639602 1639602 0 0.0
ota-provider-app debug (read only) 1633465 1633465 0 0.0
(read/write) 87560 87560 0 0.0
.bss 48768 48768 0 0.0
.data 1064 1064 0 0.0
.data.rel.ro 32216 32216 0 0.0
.dynamic 608 608 0 0.0
.got 4240 4240 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 148190 148190 0 0.0
.text 1368050 1368050 0 0.0
ota-requestor-app debug (read only) 1642177 1642177 0 0.0
(read/write) 90608 90608 0 0.0
.bss 50080 50080 0 0.0
.data 1096 1096 0 0.0
.data.rel.ro 34136 34136 0 0.0
.dynamic 592 592 0 0.0
.got 4032 4032 0 0.0
.init 27 27 0 0.0
.init_array 616 616 0 0.0
.rodata 144463 144463 0 0.0
.text 1381570 1381570 0 0.0
shell debug (read only) 2277961 2277961 0 0.0
(read/write) 148944 148944 0 0.0
.bss 70784 70784 0 0.0
.data 768 768 0 0.0
.data.rel.ro 71712 71712 0 0.0
.dynamic 592 592 0 0.0
.got 4160 4160 0 0.0
.init 27 27 0 0.0
.init_array 904 904 0 0.0
.rodata 204562 204562 0 0.0
.text 1918530 1918530 0 0.0
thermostat-no-ble arm64 (read only) 2087388 2087388 0 0.0
(read/write) 148529 148529 0 0.0
.bss 66209 66209 0 0.0
.data 952 952 0 0.0
.data.rel.ro 74248 74248 0 0.0
.dynamic 560 560 0 0.0
.got 4136 4136 0 0.0
.init 24 24 0 0.0
.init_array 344 344 0 0.0
.rodata 130780 130780 0 0.0
.text 1739280 1739280 0 0.0
tv-app debug (read only) 2408921 2409017 96 0.0
(read/write) 318000 318000 0 0.0
.bss 237344 237344 0 0.0
.data 2944 2944 0 0.0
.data.rel.ro 71720 71720 0 0.0
.dynamic 592 592 0 0.0
.got 4520 4520 0 0.0
.init 27 27 0 0.0
.init_array 872 872 0 0.0
.rodata 191948 191948 0 0.0
.text 2046498 2046594 96 0.0
mbed all-clusters-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2384584 2384584 0 0.0
.bss 189260 189260 0 0.0
.data 5288 5288 0 0.0
.text 1347184 1347184 0 0.0
lighting-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2338192 2338192 0 0.0
.bss 178176 178176 0 0.0
.data 5568 5568 0 0.0
.text 1300792 1300792 0 0.0
lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2302296 2302296 0 0.0
.bss 178056 178056 0 0.0
.data 5552 5552 0 0.0
.text 1264896 1264896 0 0.0
pigweed-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 1139712 1139712 0 0.0
.bss 11756 11756 0 0.0
.data 4368 4368 0 0.0
.text 103096 103096 0 0.0
shell CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2292964 2292964 0 0.0
.bss 175332 175332 0 0.0
.data 5368 5368 0 0.0
.text 1255536 1255536 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 (read/write) 980539 980539 0 0.0
bss 118544 118544 0 0.0
rodata 115840 115840 0 0.0
text 668364 668364 0 0.0
nrf52840dk_nrf52840+rpc (read/write) 966115 966115 0 0.0
bss 115588 115588 0 0.0
rodata 107312 107312 0 0.0
text 664808 664808 0 0.0
nrf52840dongle_nrf52840 (read/write) 996623 996623 0 0.0
bss 119716 119716 0 0.0
rodata 114672 114672 0 0.0
text 673756 673756 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 889754 889754 0 0.0
bss 115332 115332 0 0.0
rodata 109116 109116 0 0.0
text 584560 584560 0 0.0
lock-app nrf52840dk_nrf52840 (read/write) 913151 913151 0 0.0
bss 116904 116904 0 0.0
rodata 104476 104476 0 0.0
text 614368 614368 0 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 823186 823186 0 0.0
bss 113720 113720 0 0.0
rodata 97684 97684 0 0.0
text 531344 531344 0 0.0
pigweed-app nrf52840dk_nrf52840 (read/write) 541779 541779 0 0.0
bss 52588 52588 0 0.0
rodata 50048 50048 0 0.0
text 376940 376940 0 0.0
pump-app nrf52840dk_nrf52840 (read/write) 916011 916011 0 0.0
bss 116660 116660 0 0.0
rodata 104992 104992 0 0.0
text 616892 616892 0 0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 911171 911171 0 0.0
bss 116668 116668 0 0.0
rodata 104096 104096 0 0.0
text 612940 612940 0 0.0
shell nrf52840dk_nrf52840 (read/write) 798395 798395 0 0.0
bss 109776 109776 0 0.0
rodata 78352 78352 0 0.0
text 533760 533760 0 0.0
p6 all-clusters-app default (read/write) 2445880 2445880 0 0.0
.bss 117404 117404 0 0.0
.data 2576 2576 0 0.0
.text 1404144 1404144 0 0.0
light-app default (read/write) 2340320 2340320 0 0.0
.bss 103364 103364 0 0.0
.data 2408 2408 0 0.0
.text 1298584 1298584 0 0.0
lock-app default (read/write) 2305728 2305728 0 0.0
.bss 103084 103084 0 0.0
.data 2368 2368 0 0.0
.text 1263992 1263992 0 0.0
qpg lighting-app qpg6105+debug (read only) 570700 570700 0 0.0
(read/write) 146936 146936 0 0.0
.bss 87520 87520 0 0.0
.data 1060 1060 0 0.0
.text 565380 565380 0 0.0
lock-app qpg6105+debug (read only) 516816 516816 0 0.0
(read/write) 146936 146936 0 0.0
.bss 86960 86960 0 0.0
.data 996 996 0 0.0
.text 511496 511496 0 0.0
persistent-storage-app qpg6105+debug (read only) 107140 107140 0 0.0
(read/write) 146940 146940 0 0.0
.bss 38504 38504 0 0.0
.data 288 288 0 0.0
.text 101820 101820 0 0.0
telink lighting-app tlsr9518adk80d (read/write) 845134 845134 0 0.0
bss 85568 85568 0 0.0
noinit 37160 37160 0 0.0
text 592564 592564 0 0.0

@andy31415 andy31415 merged commit a2f9cad into project-chip:master Feb 1, 2022
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.

4 participants