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 when shutting down a controller with pending session setups. #26070

Merged

Conversation

bzbarsky-apple
Copy link
Contributor

When shutting down a controller, we just destroyed its pending session setups without notifying their consumers. This leaks, becase those consumers never get a "setup has failed" notification and hence can't clean up properly.

A simple way to reproduce is to build darwin-framework-tool without ASAN enabled, then run:

MallocStackLogging=YES leaks --atExit -- darwin-framework-tool onoff toggle 0xDEADBEEF 1

when no node with id 0xDEADBEEF is commissioned.

The fix is to send notifications when tearing down the OperationalSessionSetup, if we have not notified yet.

@github-actions
Copy link

PR #26070: Size comparison from f25702c to eee1f6e

Increases (1 build for cc32xx)
platform target config section f25702c eee1f6e change % change
cc32xx lock CC3235SF_LAUNCHXL (read only) 642953 642969 16 0.0
.debug_aranges 87616 87624 8 0.0
.debug_frame 301352 301372 20 0.0
.debug_info 20303346 20303529 183 0.0
.debug_line 2679969 2679998 29 0.0
.debug_loc 2824782 2824885 103 0.0
.debug_ranges 286208 286216 8 0.0
.debug_str 3039567 3039703 136 0.0
.strtab 377533 377626 93 0.0
.symtab 256800 256832 32 0.0
.text 536480 536496 16 0.0
Full report (1 build for cc32xx)
platform target config section f25702c eee1f6e change % change
cc32xx lock CC3235SF_LAUNCHXL 0 0 0 0.0
(read only) 642953 642969 16 0.0
(read/write) 203848 203848 0 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197248 197248 0 0.0
.comment 194 194 0 0.0
.data 1480 1480 0 0.0
.debug_abbrev 933129 933129 0 0.0
.debug_aranges 87616 87624 8 0.0
.debug_frame 301352 301372 20 0.0
.debug_info 20303346 20303529 183 0.0
.debug_line 2679969 2679998 29 0.0
.debug_loc 2824782 2824885 103 0.0
.debug_ranges 286208 286216 8 0.0
.debug_str 3039567 3039703 136 0.0
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 104353 104353 0 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 377533 377626 93 0.0
.symtab 256800 256832 32 0.0
.text 536480 536496 16 0.0

When shutting down a controller, we just destroyed its pending session setups
without notifying their consumers.  This leaks, becase those consumers never get
a "setup has failed" notification and hence can't clean up properly.

A simple way to reproduce is to build darwin-framework-tool without ASAN
enabled, then run:

    MallocStackLogging=YES leaks --atExit -- darwin-framework-tool onoff toggle 0xDEADBEEF 1

when no node with id 0xDEADBEEF is commissioned.

The fix is to send notifications when tearing down the OperationalSessionSetup,
if we have not notified yet.
@bzbarsky-apple bzbarsky-apple force-pushed the fix-session-setup-leak branch from eee1f6e to 0987d3f Compare April 12, 2023 16:50
@github-actions
Copy link

PR #26070: Size comparison from 2ce04b5 to 0987d3f

Increases (3 builds for cc32xx, qpg)
platform target config section 2ce04b5 0987d3f change % change
cc32xx lock CC3235SF_LAUNCHXL (read only) 642953 642969 16 0.0
.debug_aranges 87616 87624 8 0.0
.debug_frame 301352 301372 20 0.0
.debug_info 20303348 20303531 183 0.0
.debug_line 2679969 2679998 29 0.0
.debug_loc 2824782 2824885 103 0.0
.debug_ranges 286208 286216 8 0.0
.debug_str 3039567 3039703 136 0.0
.strtab 377533 377626 93 0.0
.symtab 256800 256832 32 0.0
.text 536480 536496 16 0.0
qpg lighting-app qpg6105+debug (read/write) 1154764 1154788 24 0.0
.text 601860 601884 24 0.0
lock-app qpg6105+debug (read/write) 1124844 1124868 24 0.0
.text 571944 571968 24 0.0
Full report (3 builds for cc32xx, qpg)
platform target config section 2ce04b5 0987d3f change % change
cc32xx lock CC3235SF_LAUNCHXL 0 0 0 0.0
(read only) 642953 642969 16 0.0
(read/write) 203848 203848 0 0.0
.ARM.attributes 44 44 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 197248 197248 0 0.0
.comment 194 194 0 0.0
.data 1480 1480 0 0.0
.debug_abbrev 933129 933129 0 0.0
.debug_aranges 87616 87624 8 0.0
.debug_frame 301352 301372 20 0.0
.debug_info 20303348 20303531 183 0.0
.debug_line 2679969 2679998 29 0.0
.debug_loc 2824782 2824885 103 0.0
.debug_ranges 286208 286216 8 0.0
.debug_str 3039567 3039703 136 0.0
.ramVecs 780 780 0 0.0
.resetVecs 64 64 0 0.0
.rodata 104353 104353 0 0.0
.shstrtab 232 232 0 0.0
.stab 204 204 0 0.0
.stabstr 441 441 0 0.0
.stack 2048 2048 0 0.0
.strtab 377533 377626 93 0.0
.symtab 256800 256832 32 0.0
.text 536480 536496 16 0.0
qpg lighting-app qpg6105+debug (read/write) 1154764 1154788 24 0.0
.bss 97404 97404 0 0.0
.data 836 836 0 0.0
.text 601860 601884 24 0.0
lock-app qpg6105+debug (read/write) 1124844 1124868 24 0.0
.bss 92548 92548 0 0.0
.data 840 840 0 0.0
.text 571944 571968 24 0.0

@bzbarsky-apple bzbarsky-apple merged commit 7a92beb into project-chip:master Apr 12, 2023
@bzbarsky-apple bzbarsky-apple deleted the fix-session-setup-leak branch April 12, 2023 20:59
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.

3 participants