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

Better fix for crashes around MTRBaseSubscriptionCallback. #23076

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

bzbarsky-apple
Copy link
Contributor

#22978 accidentally reintroduced the crash that
#22324 had fixed. To avoid more issues along these lines:

  1. Add unit tests that reproduce the crashes described in
    Queued deletion setup on Darwin leads to crashes #22320 (with the
    changes from [Darwin] MTRBaseSubscriptionCallback OnDone callback being called async can lead to crashes #22978) and
    [Darwin] MTRBaseSubscriptionCallback OnDone callback being called async can lead to crashes #22935 (without those
    changes).
  2. Change MTRBaseSubscriptionCallback to always invoke its callbacks
    synchronously, on the Matter queue, so that we can clean up the
    MTRClusterStateCacheContainer's pointer to the ClusterStateCache before it
    gets deleted on the Matter queue.
  3. Move the queueing of callbacks to the client queue into the consumers of
    MTRBaseSubscriptionCallback, so they can do whatever sync work they need
    (like the above cleanup) before going async.
  4. Update documentation.

@jtung-apple the MTRBaseDevice changes might be easiest to review in a whitespace-ignoring diff, because it all got reindented.

project-chip#22978 accidentally
reintroduced the crash that
project-chip#22324 had fixed.  To avoid
more issues along these lines:

1) Add unit tests that reproduce the crashes described in
   project-chip#22320 (with the
   changes from project-chip#22978) and
   project-chip#22935 (without those
   changes).
2) Change MTRBaseSubscriptionCallback to always invoke its callbacks
   synchronously, on the Matter queue, so that we can clean up the
   MTRClusterStateCacheContainer's pointer to the ClusterStateCache before it
   gets deleted on the Matter queue.
3) Move the queueing of callbacks to the client queue into the consumers of
   MTRBaseSubscriptionCallback, so they can do whatever sync work they need
   (like the above cleanup) before going async.
4) Update documentation.
@github-actions
Copy link

github-actions bot commented Oct 7, 2022

PR #23076: Size comparison from 32d8e9d to 4deb5b5

Increases (4 builds for bl702, nrfconnect, psoc6, telink)
platform target config section 32d8e9d 4deb5b5 change % change
bl702 lighting-app bl702 .debug_info 37904657 37904659 2 0.0
.text 956804 956808 4 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 text 815512 815516 4 0.0
psoc6 light cy8ckit_062s2_43012 .debug_info 22031180 22031181 1 0.0
telink lighting-app tlsr9518adk80d text 571176 571178 2 0.0
Decreases (3 builds for bl702, esp32, psoc6)
platform target config section 32d8e9d 4deb5b5 change % change
bl702 lighting-app bl702+rpc .debug_info 41811272 41811271 -1 -0.0
.text 1030510 1030508 -2 -0.0
esp32 all-clusters-app c3devkit (read only) 1223172 1223170 -2 -0.0
.flash.text 1223172 1223170 -2 -0.0
psoc6 all-clusters cy8ckit_062s2_43012 .debug_info 26830676 26830675 -1 -0.0
Full report (38 builds for bl602, bl702, cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
platform target config section 32d8e9d 4deb5b5 change % change
bl602 lighting-app bl602 (read/write) 1389242 1389242 0 0.0
.bss 90729 90729 0 0.0
.data 9928 9928 0 0.0
.text 1068834 1068834 0 0.0
bl602+rpc (read/write) 1434454 1434454 0 0.0
.bss 98161 98161 0 0.0
.data 10312 10312 0 0.0
.text 1100184 1100184 0 0.0
bl702 lighting-app bl702 (read only) 3262 3262 0 0.0
(read/write) 1188243 1188243 0 0.0
.bleromro 6296 6296 0 0.0
.bleromrw 124 124 0 0.0
.boot2 688 688 0 0.0
.bss 67102 67102 0 0.0
.bss_psram 29696 29696 0 0.0
.comment 48 48 0 0.0
.data 4272 4272 0 0.0
.debug_abbrev 1506865 1506865 0 0.0
.debug_aranges 133128 133128 0 0.0
.debug_frame 486580 486580 0 0.0
.debug_info 37904657 37904659 2 0.0
.debug_line 5256255 5256255 0 0.0
.debug_loc 3366594 3366594 0 0.0
.debug_ranges 359272 359272 0 0.0
.debug_str 3457767 3457767 0 0.0
.hbn 509 509 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 144 144 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 116552 116552 0 0.0
.rsvd 3188 3188 0 0.0
.shstrtab 293 293 0 0.0
.stack 2048 2048 0 0.0
.strtab 565071 565071 0 0.0
.symtab 171664 171664 0 0.0
.tcm_data 36 36 0 0.0
.tcmcode 3262 3262 0 0.0
.text 0 0 0 0.0
956804 956808 4 0.0
bl702+rpc (read only) 3262 3262 0 0.0
(read/write) 1284163 1284163 0 0.0
.bleromro 6296 6296 0 0.0
.bleromrw 124 124 0 0.0
.boot2 688 688 0 0.0
.bss 75150 75150 0 0.0
.bss_psram 29936 29936 0 0.0
.comment 48 48 0 0.0
.data 4800 4800 0 0.0
.debug_abbrev 1644410 1644410 0 0.0
.debug_aranges 140632 140632 0 0.0
.debug_frame 511956 511956 0 0.0
.debug_info 41811272 41811271 -1 -0.0
.debug_line 5630790 5630790 0 0.0
.debug_loc 3559254 3559254 0 0.0
.debug_ranges 381728 381728 0 0.0
.debug_str 3853667 3853667 0 0.0
.hbn 509 509 0 0.0
.hbn_noinit 260 260 0 0.0
.init 342 342 0 0.0
.init_array 160 160 0 0.0
.psram 0 0 0 0.0
.riscv.attributes 47 47 0 0.0
.rodata 129944 129944 0 0.0
.rsvd 3188 3188 0 0.0
.shstrtab 293 293 0 0.0
.stack 2048 2048 0 0.0
.strtab 624244 624244 0 0.0
.symtab 189472 189472 0 0.0
.tcm_data 36 36 0 0.0
.tcmcode 3262 3262 0 0.0
.text 0 0 0 0.0
1030510 1030508 -2 -0.0
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 676807 676807 0 0.0
(read/write) 174736 174736 0 0.0
.bss 81236 81236 0 0.0
.data 3380 3380 0 0.0
.rodata 89607 89607 0 0.0
.text 586888 586888 0 0.0
all-clusters-minimal-app LP_CC2652R7 (read only) 641055 641055 0 0.0
(read/write) 158004 158004 0 0.0
.bss 80508 80508 0 0.0
.data 3380 3380 0 0.0
.rodata 78743 78743 0 0.0
.text 561992 561992 0 0.0
lock-ftd LP_CC2652R7 (read only) 675491 675491 0 0.0
(read/write) 173204 173204 0 0.0
.bss 78476 78476 0 0.0
.data 3304 3304 0 0.0
.rodata 77131 77131 0 0.0
.text 597880 597880 0 0.0
lock-mtd LP_CC2652R7 (read only) 659247 659247 0 0.0
(read/write) 185136 185136 0 0.0
.bss 74164 74164 0 0.0
.data 3304 3304 0 0.0
.rodata 102951 102951 0 0.0
.text 555816 555816 0 0.0
pump-app LP_CC2652R7 (read only) 687543 687543 0 0.0
(read/write) 161872 161872 0 0.0
.bss 78428 78428 0 0.0
.data 3296 3296 0 0.0
.rodata 90543 90543 0 0.0
.text 596516 596516 0 0.0
pump-controller-app LP_CC2652R7 (read only) 672043 672043 0 0.0
(read/write) 177484 177484 0 0.0
.bss 78540 78540 0 0.0
.data 3292 3292 0 0.0
.rodata 86099 86099 0 0.0
.text 585464 585464 0 0.0
shell LP_CC2652R7 (read only) 667830 667830 0 0.0
(read/write) 186032 186032 0 0.0
.bss 83556 83556 0 0.0
.data 3376 3376 0 0.0
.rodata 86318 86318 0 0.0
.text 581196 581196 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 587770 587770 0 0.0
.app_xip_area 464380 464380 0 0.0
.bss 65808 65808 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) 592026 592026 0 0.0
.app_xip_area 463316 463316 0 0.0
.bss 71120 71120 0 0.0
.data 768 768 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 543586 543586 0 0.0
.app_xip_area 425252 425252 0 0.0
.bss 60800 60800 0 0.0
.data 716 716 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A+rpc (read/write) 973512 973512 0 0.0
.bss 152252 152252 0 0.0
.data 2248 2248 0 0.0
.text 818992 818992 0 0.0
BRD4161A+rs911x (read/write) 1030736 1030736 0 0.0
.bss 186656 186656 0 0.0
.data 2092 2092 0 0.0
.text 841968 841968 0 0.0
BRD4187C (read/write) 1145476 1145476 0 0.0
.bss 138640 138640 0 0.0
.data 2596 2596 0 0.0
.text 979644 979644 0 0.0
lock-app BRD4161A+wf200 (read/write) 1156792 1156792 0 0.0
.bss 158208 158208 0 0.0
.data 2100 2100 0 0.0
.text 996460 996460 0 0.0
window-app BRD4187C (read/write) 1138912 1138912 0 0.0
.bss 140080 140080 0 0.0
.data 2620 2620 0 0.0
.text 971616 971616 0 0.0
esp32 all-clusters-app c3devkit (read only) 1223172 1223170 -2 -0.0
(read/write) 1788126 1788126 0 0.0
.dram0.bss 76944 76944 0 0.0
.dram0.data 13840 13840 0 0.0
.flash.rodata 257696 257696 0 0.0
.flash.text 1223172 1223170 -2 -0.0
.iram0.text 65204 65204 0 0.0
m5stack (read only) 1233187 1233187 0 0.0
(read/write) 564020 564020 0 0.0
.dram0.bss 82312 82312 0 0.0
.dram0.data 34296 34296 0 0.0
.flash.rodata 314744 314744 0 0.0
.flash.text 1227803 1227803 0 0.0
.iram0.text 123939 123939 0 0.0
k32w contact k32w0+release (read/write) 665944 665944 0 0.0
.bss 77048 77048 0 0.0
.data 2108 2108 0 0.0
.text 567676 567676 0 0.0
light k32w0+release (read/write) 641620 641620 0 0.0
.bss 74824 74824 0 0.0
.data 2064 2064 0 0.0
.text 562004 562004 0 0.0
lock k32w0+release (read/write) 632948 632948 0 0.0
.bss 75600 75600 0 0.0
.data 2080 2080 0 0.0
.text 552540 552540 0 0.0
linux chip-tool-ipv6only arm64 (read only) 10428964 10428964 0 0.0
(read/write) 706321 706321 0 0.0
.bss 33953 33953 0 0.0
.data 2768 2768 0 0.0
.data.rel.ro 650608 650608 0 0.0
.dynamic 560 560 0 0.0
.got 13896 13896 0 0.0
.init 24 24 0 0.0
.init_array 208 208 0 0.0
.rodata 518004 518004 0 0.0
.text 8255412 8255412 0 0.0
thermostat-no-ble arm64 (read only) 2389468 2389468 0 0.0
(read/write) 143617 143617 0 0.0
.bss 55377 55377 0 0.0
.data 1816 1816 0 0.0
.data.rel.ro 77232 77232 0 0.0
.dynamic 560 560 0 0.0
.got 5176 5176 0 0.0
.init 24 24 0 0.0
.init_array 440 440 0 0.0
.rodata 144244 144244 0 0.0
.text 2002336 2002336 0 0.0
mbed lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2451856 2451856 0 0.0
.bss 215028 215028 0 0.0
.data 5872 5872 0 0.0
.text 1414500 1414500 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1183083 1183083 0 0.0
bss 144441 144441 0 0.0
rodata 144220 144220 0 0.0
text 815512 815516 4 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1161767 1161767 0 0.0
bss 143668 143668 0 0.0
rodata 135792 135792 0 0.0
text 803412 803412 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 (read only) 841968 841968 0 0.0
(read/write) 1744764 1744764 0 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 188712 188712 0 0.0
.comment 204 204 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2664 2664 0 0.0
.debug_abbrev 1229374 1229374 0 0.0
.debug_aranges 111856 111856 0 0.0
.debug_frame 373484 373484 0 0.0
.debug_info 26830676 26830675 -1 -0.0
.debug_line 3671535 3671535 0 0.0
.debug_loc 3588341 3588341 0 0.0
.debug_ranges 339640 339640 0 0.0
.debug_str 3441170 3441170 0 0.0
.heap 841968 841968 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 569639 569639 0 0.0
.symtab 421184 421184 0 0.0
.text 1545000 1545000 0 0.0
.zero.table 8 8 0 0.0
text 0 0 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 (read only) 842704 842704 0 0.0
(read/write) 1687372 1687372 0 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 187976 187976 0 0.0
.comment 204 204 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2664 2664 0 0.0
.debug_abbrev 1221173 1221173 0 0.0
.debug_aranges 111328 111328 0 0.0
.debug_frame 376564 376564 0 0.0
.debug_info 26567458 26567458 0 0.0
.debug_line 3692252 3692252 0 0.0
.debug_loc 3575978 3575978 0 0.0
.debug_ranges 338256 338256 0 0.0
.debug_str 3430183 3430183 0 0.0
.heap 842704 842704 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 533728 533728 0 0.0
.symtab 407616 407616 0 0.0
.text 1488344 1488344 0 0.0
.zero.table 0 0 0 0.0
8 8 0 0.0
light cy8ckit_062s2_43012 (read only) 850896 850896 0 0.0
(read/write) 1605900 1605900 0 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 179992 179992 0 0.0
.comment 204 204 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2456 2456 0 0.0
.debug_abbrev 1055284 1055284 0 0.0
.debug_aranges 103536 103536 0 0.0
.debug_frame 346896 346896 0 0.0
.debug_info 22031180 22031181 1 0.0
.debug_line 3262190 3262190 0 0.0
.debug_loc 3273940 3273940 0 0.0
.debug_ranges 303560 303560 0 0.0
.debug_str 3235715 3235715 0 0.0
.heap 850896 850896 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 470105 470105 0 0.0
.symtab 376064 376064 0 0.0
.text 1415064 1415064 0 0.0
.zero.table 0 0 0 0.0
8 8 0 0.0
lock cy8ckit_062s2_43012 (read only) 845880 845880 0 0.0
(read/write) 1639820 1639820 0 0.0
.ARM.attributes 46 46 0 0.0
.ARM.exidx 8 8 0 0.0
.bss 184992 184992 0 0.0
.comment 204 204 0 0.0
.copy.table 24 24 0 0.0
.cy_m0p_image 6216 6216 0 0.0
.cy_sharedmem 8 8 0 0.0
.data 2472 2472 0 0.0
.debug_abbrev 1057410 1057410 0 0.0
.debug_aranges 103936 103936 0 0.0
.debug_frame 348788 348788 0 0.0
.debug_info 22269877 22269877 0 0.0
.debug_line 3260055 3260055 0 0.0
.debug_loc 3302533 3302533 0 0.0
.debug_ranges 305504 305504 0 0.0
.debug_str 3255229 3255229 0 0.0
.heap 845880 845880 0 0.0
.noinit 148 148 0 0.0
.ramVectors 736 736 0 0.0
.shstrtab 288 288 0 0.0
.stab 156 156 0 0.0
.stabstr 335 335 0 0.0
.stack_dummy 4096 4096 0 0.0
.strtab 472512 472512 0 0.0
.symtab 377728 377728 0 0.0
.text 1443968 1443968 0 0.0
.zero.table 0 0 0 0.0
8 8 0 0.0
qpg lighting-app qpg6105+debug (read/write) 1148280 1148280 0 0.0
.bss 110556 110556 0 0.0
.data 832 832 0 0.0
.text 595380 595380 0 0.0
lock-app qpg6105+debug (read/write) 1113344 1113344 0 0.0
.bss 106372 106372 0 0.0
.data 836 836 0 0.0
.text 560440 560440 0 0.0
telink light-switch-app tlsr9518adk80d (read/write) 789000 789000 0 0.0
bss 72480 72480 0 0.0
noinit 43520 43520 0 0.0
text 552954 552954 0 0.0
lighting-app tlsr9518adk80d (read/write) 811112 811112 0 0.0
bss 73328 73328 0 0.0
noinit 43520 43520 0 0.0
text 571176 571178 2 0.0
ota-requestor-app tlsr9518adk80d (read/write) 819048 819048 0 0.0
bss 74236 74236 0 0.0
noinit 43520 43520 0 0.0
text 577360 577360 0 0.0

@andy31415 andy31415 enabled auto-merge (squash) October 11, 2022 14:22
@andy31415 andy31415 merged commit a7475d3 into project-chip:master Oct 11, 2022
@bzbarsky-apple bzbarsky-apple deleted the re-fix-darwin-crashes branch October 11, 2022 14:29
selissia pushed a commit to selissia/connectedhomeip that referenced this pull request Oct 12, 2022
…hip#23076)

project-chip#22978 accidentally
reintroduced the crash that
project-chip#22324 had fixed.  To avoid
more issues along these lines:

1) Add unit tests that reproduce the crashes described in
   project-chip#22320 (with the
   changes from project-chip#22978) and
   project-chip#22935 (without those
   changes).
2) Change MTRBaseSubscriptionCallback to always invoke its callbacks
   synchronously, on the Matter queue, so that we can clean up the
   MTRClusterStateCacheContainer's pointer to the ClusterStateCache before it
   gets deleted on the Matter queue.
3) Move the queueing of callbacks to the client queue into the consumers of
   MTRBaseSubscriptionCallback, so they can do whatever sync work they need
   (like the above cleanup) before going async.
4) Update documentation.
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