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 UnauthenticatedSession leak #10754

Merged

Conversation

kghost
Copy link
Contributor

@kghost kghost commented Oct 21, 2021

Problem

#10493

The root cause of this is that the initial reference count of UnauthenticatedSession is set to 1, but it should be 0.

Change overview

  • Use UnauthenticatedSessionHandle to guard all UnauthenticatedSession usages.
  • make UnauthenticatedSessionTable::AllocEntry and FindEntry private, because they are using raw pointer of UnauthenticatedSession

Testing

  • Verified by unit-tests
  • Manually checked that the session is freed after commissioning.

@franck-apple franck-apple added this to the Test Event 7 milestone Oct 21, 2021
@boring-cyborg boring-cyborg bot added the lib label Oct 22, 2021
@kghost kghost force-pushed the te6-fix-unauthenticated-session branch from 5c65962 to de0c8f0 Compare October 22, 2021 11:19
@github-actions
Copy link

github-actions bot commented Oct 22, 2021

PR #10754: Size comparison from 0c16976 to de0c8f0

12 builds (for efr32, k32w, p6, qpg, telink)
platform target config section 0c16976 de0c8f0 change % change
efr32 lighting-app BRD4161A .bss 118028 118028 0 0.0
.data 1800 1800 0 0.0
.text 784328 784552 224 0.0
lock-app BRD4161A .bss 115884 115884 0 0.0
.data 1760 1760 0 0.0
.text 763456 763696 240 0.0
window-app BRD4161A .bss 116204 116204 0 0.0
.data 1764 1764 0 0.0
.text 764380 764604 224 0.0
lighting-app BRD4161A+rpc .bss 131356 131356 0 0.0
.data 1852 1852 0 0.0
.text 764028 764268 240 0.0
k32w lock-app k32w061+debug .bss 69060 69060 0 0.0
.data 1864 1864 0 0.0
.text 516068 516052 -16 -0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 359544 359512 -32 -0.0
lighting-app k32w061+se05x+release .bss 78592 78592 0 0.0
.data 1900 1900 0 0.0
.text 614836 614820 -16 -0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126688 1126912 224 0.0
qpg lighting-app qpg6100+debug .bss 53552 53552 0 0.0
.data 1004 1004 0 0.0
.text 485972 485956 -16 -0.0
lock-app qpg6100+debug .bss 52496 52496 0 0.0
.data 960 960 0 0.0
.text 462060 462044 -16 -0.0
persistent-storage-app qpg6100+debug .bss 27840 27840 0 0.0
.data 372 372 0 0.0
.text 149896 149896 0 0.0
telink lighting-app tlsr9518adk80d bss 70996 70996 0 0.0
noinit 33216 33216 0 0.0
text 457630 457682 52 0.0
10 builds (for linux, mbed)
platform target config section 0c16976 de0c8f0 change % change
linux all-clusters-app debug .bss 52208 52208 0 0.0
.data 978 978 0 0.0
.data.rel.ro 60384 60384 0 0.0
.dynamic 592 592 0 0.0
.got 4088 4088 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136405 136405 0 0.0
.text 1352290 1352754 464 0.0
chip-tool debug .bss 17712 17712 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 93504 93504 0 0.0
.dynamic 592 592 0 0.0
.got 4368 4368 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 193860 193860 0 0.0
.text 3502693 3503253 560 0.0
ota-provider-app debug .bss 37472 37472 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4016 4016 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 110248 110248 0 0.0
.text 1022226 1022690 464 0.0
ota-requestor-app debug .bss 205728 205728 0 0.0
.data 752 752 0 0.0
.data.rel.ro 25800 25800 0 0.0
.dynamic 592 592 0 0.0
.got 4144 4144 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128392 128360 -32 -0.0
.text 1140786 1141330 544 0.0
shell debug .bss 16136 16136 0 0.0
.data 242 242 0 0.0
.data.rel.ro 36496 36496 0 0.0
.dynamic 592 592 0 0.0
.got 3528 3528 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 76463 76463 0 0.0
.text 597346 597826 480 0.1
tv-app debug .bss 216592 216592 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 57408 57408 0 0.0
.dynamic 592 592 0 0.0
.got 4408 4408 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152904 152904 0 0.0
.text 1452706 1453266 560 0.0
bridge-app debug+rpc .bss 52912 52912 0 0.0
.data 976 976 0 0.0
.data.rel.ro 27112 27112 0 0.0
.dynamic 592 592 0 0.0
.got 3952 3952 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110748 110748 0 0.0
.text 1063173 1063637 464 0.0
lighting-app debug+rpc .bss 42232 42232 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 53808 53808 0 0.0
.dynamic 608 608 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127921 127921 0 0.0
.text 1261170 1261634 464 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172100 172100 0 0.0
.data 5464 5464 0 0.0
.heap 858880 858880 0 0.0
.text 1220088 1220088 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171020 171020 0 0.0
.data 5432 5432 0 0.0
.heap 859992 859992 0 0.0
.text 1197984 1197984 0 0.0
12 builds (for esp32, nrfconnect)
platform target config section 0c16976 de0c8f0 change % change
esp32 all-clusters-app c3devkit .dram0.bss 60296 60296 0 0.0
.dram0.data 16440 16440 0 0.0
.flash.rodata 199864 199864 0 0.0
.flash.text 874330 874306 -24 -0.0
.iram0.text 57564 57564 0 0.0
m5stack .dram0.bss 62800 62800 0 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 208600 208600 0 0.0
.flash.text 905263 905399 136 0.0
.iram0.text 125115 125115 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 bss 113176 113176 0 0.0
rodata 98076 98076 0 0.0
text 577104 577196 92 0.0
lock-app nrf52840dk_nrf52840 bss 112244 112244 0 0.0
rodata 94412 94412 0 0.0
text 558592 558684 92 0.0
pigweed-app nrf52840dk_nrf52840 bss 51824 51824 0 0.0
rodata 45776 45776 0 0.0
text 339456 339456 0 0.0
pump-app nrf52840dk_nrf52840 bss 112312 112312 0 0.0
rodata 95396 95396 0 0.0
text 561744 561836 92 0.0
pump-controller-app nrf52840dk_nrf52840 bss 112252 112252 0 0.0
rodata 94472 94472 0 0.0
text 558384 558476 92 0.0
shell nrf52840dk_nrf52840 bss 109072 109072 0 0.0
rodata 72524 72524 0 0.0
text 520208 520300 92 0.0
lighting-app nrf52840dk_nrf52840+rpc bss 109420 109420 0 0.0
rodata 88856 88856 0 0.0
text 550296 550388 92 0.0
nrf5340dk_nrf5340_cpuapp bss 114552 114552 0 0.0
rodata 93316 93316 0 0.0
text 506572 506664 92 0.0
lock-app nrf5340dk_nrf5340_cpuapp bss 113616 113616 0 0.0
rodata 89672 89672 0 0.0
text 488056 488148 92 0.0
shell nrf5340dk_nrf5340_cpuapp bss 110056 110056 0 0.0
rodata 67168 67168 0 0.0
text 440816 440908 92 0.0

@woody-apple
Copy link
Contributor

/rebase

@woody-apple woody-apple force-pushed the te6-fix-unauthenticated-session branch from de0c8f0 to e4cc0dd Compare October 22, 2021 16:56
@kghost kghost force-pushed the te6-fix-unauthenticated-session branch from e4cc0dd to e172d0d Compare October 22, 2021 18:01
src/lib/core/Optional.h Outdated Show resolved Hide resolved
@kghost kghost force-pushed the te6-fix-unauthenticated-session branch from e172d0d to 19a9966 Compare October 22, 2021 19:08
@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from e282eec

File Section File VM
chip-shell.elf text 92 92
chip-shell.elf device_handles -12 -12
chip-lock.elf text 92 92
chip-lock.elf device_handles 4 4
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize
.debug_info,0,7532
.debug_str,0,1395
.debug_line,0,697
.debug_loc,0,521
.debug_ranges,0,128
text,92,92
device_handles,-12,-12
.debug_frame,0,-20
.debug_abbrev,0,-37

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.debug_info,0,17414
.debug_str,0,1441
.debug_line,0,867
.debug_loc,0,759
.debug_ranges,0,128
text,92,92
device_handles,4,4
.debug_frame,0,-20
.debug_abbrev,0,-37


@github-actions
Copy link

Size increase report for "esp32-example-build" from e282eec

File Section File VM
chip-all-clusters-app.elf .flash.text -24 -24
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize
.debug_info,0,22194
.debug_str,0,1377
.debug_line,0,369
[Unmapped],0,24
.strtab,0,23
.riscv.attributes,0,2
.shstrtab,0,-3
.debug_frame,0,-20
.flash.text,-24,-24
.debug_abbrev,0,-26
.debug_ranges,0,-32
.debug_loc,0,-48


@github-actions
Copy link

PR #10754: Size comparison from e282eec to 19a9966

35 builds (for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
platform target config section e282eec 19a9966 change % change
efr32 lighting-app BRD4161A .bss 118036 118036 0 0.0
.data 1800 1800 0 0.0
.text 784296 784536 240 0.0
lock-app BRD4161A .bss 115884 115884 0 0.0
.data 1760 1760 0 0.0
.text 763440 763664 224 0.0
window-app BRD4161A .bss 116204 116204 0 0.0
.data 1764 1764 0 0.0
.text 764356 764596 240 0.0
lighting-app BRD4161A+rpc .bss 131364 131364 0 0.0
.data 1852 1852 0 0.0
.text 764012 764236 224 0.0
esp32 all-clusters-app c3devkit .dram0.bss 60296 60296 0 0.0
.dram0.data 16440 16440 0 0.0
.flash.rodata 199912 199912 0 0.0
.flash.text 874326 874302 -24 -0.0
.iram0.text 57564 57564 0 0.0
m5stack .dram0.bss 62808 62808 0 0.0
.dram0.data 32084 32084 0 0.0
.flash.rodata 208648 208648 0 0.0
.flash.text 905335 905299 -36 -0.0
.iram0.text 125115 125115 0 0.0
k32w lock-app k32w061+debug .bss 69068 69068 0 0.0
.data 1864 1864 0 0.0
.text 516024 515992 -32 -0.0
shell k32w061+debug .bss 55080 55080 0 0.0
.data 672 672 0 0.0
.text 359480 359464 -16 -0.0
lighting-app k32w061+se05x+release .bss 78592 78592 0 0.0
.data 1900 1900 0 0.0
.text 614788 614772 -16 -0.0
linux all-clusters-app debug .bss 52208 52208 0 0.0
.data 978 978 0 0.0
.data.rel.ro 60384 60384 0 0.0
.dynamic 592 592 0 0.0
.got 4088 4088 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 136437 136437 0 0.0
.text 1352610 1353074 464 0.0
chip-tool debug .bss 17712 17712 0 0.0
.data 1584 1584 0 0.0
.data.rel.ro 93584 93584 0 0.0
.dynamic 592 592 0 0.0
.got 4368 4368 0 0.0
.init 27 27 0 0.0
.init_array 416 416 0 0.0
.rodata 194148 194148 0 0.0
.text 3506501 3507061 560 0.0
ota-provider-app debug .bss 37472 37472 0 0.0
.data 752 752 0 0.0
.data.rel.ro 24488 24488 0 0.0
.dynamic 592 592 0 0.0
.got 4016 4016 0 0.0
.init 27 27 0 0.0
.init_array 440 440 0 0.0
.rodata 110312 110312 0 0.0
.text 1022578 1023042 464 0.0
ota-requestor-app debug .bss 205728 205728 0 0.0
.data 752 752 0 0.0
.data.rel.ro 25800 25800 0 0.0
.dynamic 592 592 0 0.0
.got 4144 4144 0 0.0
.init 27 27 0 0.0
.init_array 512 512 0 0.0
.rodata 128392 128360 -32 -0.0
.text 1141106 1141650 544 0.0
shell debug .bss 16136 16136 0 0.0
.data 242 242 0 0.0
.data.rel.ro 36496 36496 0 0.0
.dynamic 592 592 0 0.0
.got 3528 3528 0 0.0
.init 27 27 0 0.0
.init_array 336 336 0 0.0
.rodata 76463 76463 0 0.0
.text 598242 598722 480 0.1
tv-app debug .bss 216592 216592 0 0.0
.data 2032 2032 0 0.0
.data.rel.ro 57408 57408 0 0.0
.dynamic 592 592 0 0.0
.got 4408 4408 0 0.0
.init 27 27 0 0.0
.init_array 608 608 0 0.0
.rodata 152936 152936 0 0.0
.text 1452994 1453538 544 0.0
bridge-app debug+rpc .bss 52912 52912 0 0.0
.data 976 976 0 0.0
.data.rel.ro 27112 27112 0 0.0
.dynamic 592 592 0 0.0
.got 3952 3952 0 0.0
.init 27 27 0 0.0
.init_array 400 400 0 0.0
.rodata 110748 110748 0 0.0
.text 1063461 1063925 464 0.0
lighting-app debug+rpc .bss 42232 42232 0 0.0
.data 1106 1106 0 0.0
.data.rel.ro 53808 53808 0 0.0
.dynamic 608 608 0 0.0
.got 4112 4112 0 0.0
.init 27 27 0 0.0
.init_array 528 528 0 0.0
.rodata 127921 127921 0 0.0
.text 1261410 1261874 464 0.0
mbed lighting-app CY8CPROTO_062_4343W+release .bss 172100 172100 0 0.0
.data 5464 5464 0 0.0
.heap 858880 858880 0 0.0
.text 1220088 1220088 0 0.0
lock-app CY8CPROTO_062_4343W+release .bss 171020 171020 0 0.0
.data 5432 5432 0 0.0
.heap 859992 859992 0 0.0
.text 1197992 1197928 -64 -0.0
pigweed-app CY8CPROTO_062_4343W+release .bss 11760 11760 0 0.0
.data 4360 4360 0 0.0
.heap 1020328 1020328 0 0.0
.text 103064 103064 0 0.0
nrfconnect lighting-app nrf52840dk_nrf52840 bss 113180 113180 0 0.0
rodata 98080 98080 0 0.0
text 577104 577196 92 0.0
lock-app nrf52840dk_nrf52840 bss 112244 112244 0 0.0
rodata 94416 94416 0 0.0
text 558592 558684 92 0.0
pigweed-app nrf52840dk_nrf52840 bss 51824 51824 0 0.0
rodata 45776 45776 0 0.0
text 339456 339456 0 0.0
pump-app nrf52840dk_nrf52840 bss 112316 112316 0 0.0
rodata 95396 95396 0 0.0
text 561744 561836 92 0.0
pump-controller-app nrf52840dk_nrf52840 bss 112252 112252 0 0.0
rodata 94476 94476 0 0.0
text 558384 558476 92 0.0
shell nrf52840dk_nrf52840 bss 109072 109072 0 0.0
rodata 72524 72524 0 0.0
text 520208 520300 92 0.0
lighting-app nrf52840dk_nrf52840+rpc bss 109420 109420 0 0.0
rodata 88856 88856 0 0.0
text 550296 550388 92 0.0
nrf5340dk_nrf5340_cpuapp bss 114552 114552 0 0.0
rodata 93320 93320 0 0.0
text 506572 506664 92 0.0
lock-app nrf5340dk_nrf5340_cpuapp bss 113620 113620 0 0.0
rodata 89676 89676 0 0.0
text 488056 488148 92 0.0
shell nrf5340dk_nrf5340_cpuapp bss 110056 110056 0 0.0
rodata 67168 67168 0 0.0
text 440816 440908 92 0.0
p6 lock-app default .bss 68216 68216 0 0.0
.data 2416 2416 0 0.0
.heap 962712 962712 0 0.0
.text 1126688 1126928 240 0.0
qpg lighting-app qpg6100+debug .bss 53464 53464 0 0.0
.data 1004 1004 0 0.0
.text 486036 486012 -24 -0.0
lock-app qpg6100+debug .bss 52408 52408 0 0.0
.data 960 960 0 0.0
.text 462120 462104 -16 -0.0
persistent-storage-app qpg6100+debug .bss 27752 27752 0 0.0
.data 372 372 0 0.0
.text 149896 149896 0 0.0
telink lighting-app tlsr9518adk80d bss 71000 71000 0 0.0
noinit 33216 33216 0 0.0
text 457612 457664 52 0.0

@woody-apple woody-apple merged commit ddb0bf5 into project-chip:master Oct 22, 2021
@kghost kghost deleted the te6-fix-unauthenticated-session branch October 23, 2021 07:05
jimlyall-q pushed a commit to jimlyall-q/connectedhomeip that referenced this pull request Oct 29, 2021
* Fix UnauthenticatedSession leak

* Resovle comments
kghost added a commit to kghost/connectedhomeip that referenced this pull request Nov 2, 2021
* Fix UnauthenticatedSession leak

* Resovle comments
kghost added a commit to kghost/connectedhomeip that referenced this pull request Nov 2, 2021
* Fix UnauthenticatedSession leak

* Resovle comments
andy31415 pushed a commit that referenced this pull request Nov 3, 2021
* Fix UnauthenticatedSession leak

* Resovle comments
pankore pushed a commit to pankore/connectedhomeip that referenced this pull request Nov 24, 2021
)

* Fix UnauthenticatedSession leak

* Resovle comments
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.

7 participants