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 Python event-loop & object lifetimes (for reads/writes) #19832

Merged

Conversation

mrjerryjohns
Copy link
Contributor

Problem

Possible fix to #19818 by:

  1. Ensuring that we only set the result/exception on the returned Future to the caller as part of handling onDone. This ensures that the provided event loop is still valid right till the very end.
  2. Only decrement the ref on the ctypes object at the very end of handling onDone executed on the right event loop. It's currently being decremented on the Matter thread, which is likely causing a use-after-free in Python.

@github-actions
Copy link

github-actions bot commented Jun 22, 2022

PR #19832: Size comparison from cabb0df to dacee74

Decreases (3 builds for k32w, mbed, telink)
platform target config section cabb0df dacee74 change % change
k32w lock k32w061+release (read/write) 723204 723188 -16 -0.0
.text 645200 645184 -16 -0.0
mbed lock-app CY8CPROTO_062_4343W+release (read/write) 2439136 2439072 -64 -0.0
.text 1401780 1401716 -64 -0.0
telink light-switch-app tlsr9518adk80d (read/write) 791728 791720 -8 -0.0
text 560402 560400 -2 -0.0
Full report (41 builds for cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
platform target config section cabb0df dacee74 change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 660135 660135 0 0.0
(read/write) 191472 191472 0 0.0
.bss 74500 74500 0 0.0
.data 3356 3356 0 0.0
.rodata 87239 87239 0 0.0
.text 572584 572584 0 0.0
all-clusters-minimal-app LP_CC2652R7 (read only) 648947 648947 0 0.0
(read/write) 158060 158060 0 0.0
.bss 73788 73788 0 0.0
.data 3356 3356 0 0.0
.rodata 90771 90771 0 0.0
.text 557856 557856 0 0.0
lock-ftd LP_CC2652R7 (read only) 691543 691543 0 0.0
(read/write) 150176 150176 0 0.0
.bss 71500 71500 0 0.0
.data 3280 3280 0 0.0
.rodata 99551 99551 0 0.0
.text 591508 591508 0 0.0
lock-mtd LP_CC2652R7 (read only) 640951 640951 0 0.0
(read/write) 144632 144632 0 0.0
.bss 67236 67236 0 0.0
.data 3280 3280 0 0.0
.rodata 99431 99431 0 0.0
.text 541028 541028 0 0.0
pump-app LP_CC2652R7 (read only) 672799 672799 0 0.0
(read/write) 169816 169816 0 0.0
.bss 71628 71628 0 0.0
.data 3280 3280 0 0.0
.rodata 87903 87903 0 0.0
.text 584412 584412 0 0.0
pump-controller-app LP_CC2652R7 (read only) 658683 658683 0 0.0
(read/write) 184044 184044 0 0.0
.bss 71740 71740 0 0.0
.data 3276 3276 0 0.0
.rodata 83747 83747 0 0.0
.text 574456 574456 0 0.0
shell LP_CC2652R7 (read only) 689870 689870 0 0.0
(read/write) 157240 157240 0 0.0
.bss 76804 76804 0 0.0
.data 3360 3360 0 0.0
.rodata 110022 110022 0 0.0
.text 579536 579536 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 591082 591082 0 0.0
.app_xip_area 461980 461980 0 0.0
.bss 72064 72064 0 0.0
.data 716 716 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 588466 588466 0 0.0
.app_xip_area 459188 459188 0 0.0
.bss 72240 72240 0 0.0
.data 720 720 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 593882 593882 0 0.0
.app_xip_area 465652 465652 0 0.0
.bss 71248 71248 0 0.0
.data 660 660 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 925656 925656 0 0.0
(read/write) 133664 133664 0 0.0
.bss 131584 131584 0 0.0
.data 2080 2080 0 0.0
.text 925648 925648 0 0.0
BRD4161A+rpc (read only) 961360 961360 0 0.0
(read/write) 150552 150552 0 0.0
.bss 148264 148264 0 0.0
.data 2284 2284 0 0.0
.text 961352 961352 0 0.0
BRD4161A+rs911x (read only) 801004 801004 0 0.0
(read/write) 129940 129940 0 0.0
.bss 127852 127852 0 0.0
.data 2088 2088 0 0.0
.text 800996 800996 0 0.0
lock-app BRD4161A+wf200 (read only) 967280 967280 0 0.0
(read/write) 130316 130316 0 0.0
.bss 128228 128228 0 0.0
.data 2088 2088 0 0.0
.text 967272 967272 0 0.0
window-app BRD4161A (read only) 910800 910800 0 0.0
(read/write) 133768 133768 0 0.0
.bss 131656 131656 0 0.0
.data 2108 2108 0 0.0
.text 910792 910792 0 0.0
esp32 all-clusters-app c3devkit (read only) 1013710 1013710 0 0.0
(read/write) 1484786 1484786 0 0.0
.dram0.bss 70640 70640 0 0.0
.dram0.data 14632 14632 0 0.0
.flash.rodata 214080 214080 0 0.0
.flash.text 1013710 1013710 0 0.0
.iram0.text 62902 62902 0 0.0
m5stack (read only) 1068163 1068163 0 0.0
(read/write) 486872 486872 0 0.0
.dram0.bss 76152 76152 0 0.0
.dram0.data 34144 34144 0 0.0
.flash.rodata 244580 244580 0 0.0
.flash.text 1062779 1062779 0 0.0
.iram0.text 123267 123267 0 0.0
k32w light k32w061+release (read/write) 660652 660652 0 0.0
.bss 69756 69756 0 0.0
.data 1992 1992 0 0.0
.text 583104 583104 0 0.0
lock k32w061+release (read/write) 723204 723188 -16 -0.0
.bss 70204 70204 0 0.0
.data 2000 2000 0 0.0
.text 645200 645184 -16 -0.0
linux all-clusters-app debug (read only) 2936329 2936329 0 0.0
(read/write) 177072 177072 0 0.0
.bss 84160 84160 0 0.0
.data 2048 2048 0 0.0
.data.rel.ro 84664 84664 0 0.0
.dynamic 608 608 0 0.0
.got 4536 4536 0 0.0
.init 27 27 0 0.0
.init_array 1032 1032 0 0.0
.rodata 261309 261309 0 0.0
.text 2498578 2498578 0 0.0
all-clusters-minimal-app debug (read only) 2790073 2790073 0 0.0
(read/write) 168976 168976 0 0.0
.bss 83488 83488 0 0.0
.data 2048 2048 0 0.0
.data.rel.ro 77304 77304 0 0.0
.dynamic 608 608 0 0.0
.got 4488 4488 0 0.0
.init 27 27 0 0.0
.init_array 1032 1032 0 0.0
.rodata 262877 262877 0 0.0
.text 2352930 2352930 0 0.0
bridge-app debug+rpc (read only) 2292737 2292737 0 0.0
(read/write) 147872 147872 0 0.0
.bss 71584 71584 0 0.0
.data 3792 3792 0 0.0
.data.rel.ro 66728 66728 0 0.0
.dynamic 608 608 0 0.0
.got 4400 4400 0 0.0
.init 27 27 0 0.0
.init_array 728 728 0 0.0
.rodata 196096 196096 0 0.0
.text 1935458 1935458 0 0.0
chip-tool debug (read only) 10188205 10188205 0 0.0
(read/write) 611496 611496 0 0.0
.bss 24416 24416 0 0.0
.data 1088 1088 0 0.0
.data.rel.ro 579712 579712 0 0.0
.dynamic 624 624 0 0.0
.got 5008 5008 0 0.0
.init 27 27 0 0.0
.init_array 640 640 0 0.0
.rodata 511189 511189 0 0.0
.text 8266821 8266821 0 0.0
chip-tool-no-interactive-ipv6only arm64 (read only) 9922796 9922796 0 0.0
(read/write) 676177 676177 0 0.0
.bss 42641 42641 0 0.0
.data 1152 1152 0 0.0
.data.rel.ro 615112 615112 0 0.0
.dynamic 528 528 0 0.0
.got 13464 13464 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 473836 473836 0 0.0
.text 7907924 7907924 0 0.0
lighting-app debug+rpc (read only) 2525433 2525433 0 0.0
(read/write) 151928 151928 0 0.0
.bss 72064 72064 0 0.0
.data 2064 2064 0 0.0
.data.rel.ro 71896 71896 0 0.0
.dynamic 608 608 0 0.0
.got 4432 4432 0 0.0
.init 27 27 0 0.0
.init_array 816 816 0 0.0
.rodata 211848 211848 0 0.0
.text 2143794 2143794 0 0.0
lock-app debug (read only) 2464129 2464129 0 0.0
(read/write) 146608 146608 0 0.0
.bss 70464 70464 0 0.0
.data 1680 1680 0 0.0
.data.rel.ro 68600 68600 0 0.0
.dynamic 608 608 0 0.0
.got 4432 4432 0 0.0
.init 27 27 0 0.0
.init_array 776 776 0 0.0
.rodata 225544 225544 0 0.0
.text 2074194 2074194 0 0.0
ota-provider-app debug (read only) 2302081 2302081 0 0.0
(read/write) 140712 140712 0 0.0
.bss 70144 70144 0 0.0
.data 1912 1912 0 0.0
.data.rel.ro 62840 62840 0 0.0
.dynamic 608 608 0 0.0
.got 4496 4496 0 0.0
.init 27 27 0 0.0
.init_array 672 672 0 0.0
.rodata 201784 201784 0 0.0
.text 1938050 1938050 0 0.0
ota-requestor-app debug (read only) 2417873 2417873 0 0.0
(read/write) 147424 147424 0 0.0
.bss 72448 72448 0 0.0
.data 2200 2200 0 0.0
.data.rel.ro 66936 66936 0 0.0
.dynamic 608 608 0 0.0
.got 4488 4488 0 0.0
.init 27 27 0 0.0
.init_array 728 728 0 0.0
.rodata 205440 205440 0 0.0
.text 2041954 2041954 0 0.0
shell debug (read only) 2610177 2610177 0 0.0
(read/write) 196088 196088 0 0.0
.bss 111304 111304 0 0.0
.data 1232 1232 0 0.0
.data.rel.ro 77808 77808 0 0.0
.dynamic 608 608 0 0.0
.got 4168 4168 0 0.0
.init 27 27 0 0.0
.init_array 936 936 0 0.0
.rodata 231506 231506 0 0.0
.text 2218914 2218914 0 0.0
thermostat-no-ble arm64 (read only) 2576084 2576084 0 0.0
(read/write) 180593 180593 0 0.0
.bss 87889 87889 0 0.0
.data 1688 1688 0 0.0
.data.rel.ro 82928 82928 0 0.0
.dynamic 528 528 0 0.0
.got 5072 5072 0 0.0
.init 24 24 0 0.0
.init_array 400 400 0 0.0
.rodata 164196 164196 0 0.0
.text 2172768 2172768 0 0.0
tv-app debug (read only) 3074065 3074065 0 0.0
(read/write) 277800 277800 0 0.0
.bss 187688 187688 0 0.0
.data 4656 4656 0 0.0
.data.rel.ro 79016 79016 0 0.0
.dynamic 608 608 0 0.0
.got 4840 4840 0 0.0
.init 27 27 0 0.0
.init_array 952 952 0 0.0
.rodata 247456 247456 0 0.0
.text 2639746 2639746 0 0.0
tv-casting-app debug (read only) 5539521 5539521 0 0.0
(read/write) 184112 184112 0 0.0
.bss 72872 72872 0 0.0
.data 2448 2448 0 0.0
.data.rel.ro 102576 102576 0 0.0
.dynamic 608 608 0 0.0
.got 4712 4712 0 0.0
.init 27 27 0 0.0
.init_array 864 864 0 0.0
.rodata 341417 341417 0 0.0
.text 4921874 4921874 0 0.0
mbed lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2439136 2439072 -64 -0.0
.bss 212180 212180 0 0.0
.data 5864 5864 0 0.0
.text 1401780 1401716 -64 -0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1201111 1201111 0 0.0
bss 142846 142846 0 0.0
rodata 156312 156312 0 0.0
text 823128 823128 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1149199 1149199 0 0.0
bss 142098 142098 0 0.0
rodata 132840 132840 0 0.0
text 795348 795348 0 0.0
p6 all-clusters-app default (read/write) 2555440 2555440 0 0.0
.bss 147360 147360 0 0.0
.data 2776 2776 0 0.0
.text 1513704 1513704 0 0.0
all-clusters-minimal-app default (read/write) 2501288 2501288 0 0.0
.bss 146640 146640 0 0.0
.data 2776 2776 0 0.0
.text 1459552 1459552 0 0.0
light-app default (read/write) 2432064 2432064 0 0.0
.bss 138720 138720 0 0.0
.data 2592 2592 0 0.0
.text 1390328 1390328 0 0.0
lock-app default (read/write) 2452776 2452776 0 0.0
.bss 138544 138544 0 0.0
.data 2600 2600 0 0.0
.text 1411040 1411040 0 0.0
telink light-switch-app tlsr9518adk80d (read/write) 791728 791720 -8 -0.0
bss 71140 71140 0 0.0
noinit 40416 40416 0 0.0
text 560402 560400 -2 -0.0
lighting-app tlsr9518adk80d (read/write) 811432 811432 0 0.0
bss 71388 71388 0 0.0
noinit 40416 40416 0 0.0
text 576864 576864 0 0.0

@github-actions
Copy link

github-actions bot commented Jun 22, 2022

PR #19832: Size comparison from d1a4bb7 to 0c077f7

Increases (2 builds for linux, telink)
platform target config section d1a4bb7 0c077f7 change % change
linux chip-tool-no-interactive-ipv6only arm64 (read only) 9925180 9925468 288 0.0
.rodata 473916 473932 16 0.0
.text 7910292 7910564 272 0.0
telink lighting-app tlsr9518adk80d (read/write) 811784 811792 8 0.0
text 577520 577522 2 0.0
Full report (30 builds for cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
platform target config section d1a4bb7 0c077f7 change % change
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 660439 660439 0 0.0
(read/write) 191168 191168 0 0.0
.bss 74500 74500 0 0.0
.data 3356 3356 0 0.0
.rodata 86975 86975 0 0.0
.text 573152 573152 0 0.0
all-clusters-minimal-app LP_CC2652R7 (read only) 649251 649251 0 0.0
(read/write) 158060 158060 0 0.0
.bss 73788 73788 0 0.0
.data 3356 3356 0 0.0
.rodata 90507 90507 0 0.0
.text 558424 558424 0 0.0
lock-ftd LP_CC2652R7 (read only) 691999 691999 0 0.0
(read/write) 149720 149720 0 0.0
.bss 71500 71500 0 0.0
.data 3280 3280 0 0.0
.rodata 99351 99351 0 0.0
.text 592164 592164 0 0.0
lock-mtd LP_CC2652R7 (read only) 641415 641415 0 0.0
(read/write) 144632 144632 0 0.0
.bss 67236 67236 0 0.0
.data 3280 3280 0 0.0
.rodata 99239 99239 0 0.0
.text 541684 541684 0 0.0
pump-app LP_CC2652R7 (read only) 673231 673231 0 0.0
(read/write) 169384 169384 0 0.0
.bss 71628 71628 0 0.0
.data 3280 3280 0 0.0
.rodata 87663 87663 0 0.0
.text 585084 585084 0 0.0
pump-controller-app LP_CC2652R7 (read only) 659123 659123 0 0.0
(read/write) 183604 183604 0 0.0
.bss 71740 71740 0 0.0
.data 3276 3276 0 0.0
.rodata 83507 83507 0 0.0
.text 575136 575136 0 0.0
shell LP_CC2652R7 (read only) 690198 690198 0 0.0
(read/write) 156912 156912 0 0.0
.bss 76804 76804 0 0.0
.data 3360 3360 0 0.0
.rodata 109758 109758 0 0.0
.text 580128 580128 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 591730 591730 0 0.0
.app_xip_area 462628 462628 0 0.0
.bss 72064 72064 0 0.0
.data 716 716 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 589106 589106 0 0.0
.app_xip_area 459828 459828 0 0.0
.bss 72240 72240 0 0.0
.data 720 720 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 594250 594250 0 0.0
.app_xip_area 466020 466020 0 0.0
.bss 71248 71248 0 0.0
.data 660 660 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read only) 926072 926072 0 0.0
(read/write) 133664 133664 0 0.0
.bss 131584 131584 0 0.0
.data 2080 2080 0 0.0
.text 926064 926064 0 0.0
BRD4161A+rpc (read only) 963216 963216 0 0.0
(read/write) 150552 150552 0 0.0
.bss 148264 148264 0 0.0
.data 2284 2284 0 0.0
.text 963208 963208 0 0.0
BRD4161A+rs911x (read only) 802580 802580 0 0.0
(read/write) 140316 140316 0 0.0
.bss 138228 138228 0 0.0
.data 2088 2088 0 0.0
.text 802572 802572 0 0.0
lock-app BRD4161A+wf200 (read only) 968288 968288 0 0.0
(read/write) 140692 140692 0 0.0
.bss 138604 138604 0 0.0
.data 2088 2088 0 0.0
.text 968280 968280 0 0.0
window-app BRD4161A (read only) 911240 911240 0 0.0
(read/write) 133768 133768 0 0.0
.bss 131656 131656 0 0.0
.data 2108 2108 0 0.0
.text 911232 911232 0 0.0
esp32 all-clusters-app c3devkit (read only) 1014134 1014134 0 0.0
(read/write) 1484770 1484770 0 0.0
.dram0.bss 70640 70640 0 0.0
.dram0.data 14632 14632 0 0.0
.flash.rodata 214064 214064 0 0.0
.flash.text 1014134 1014134 0 0.0
.iram0.text 62902 62902 0 0.0
m5stack (read only) 1068459 1068459 0 0.0
(read/write) 486856 486856 0 0.0
.dram0.bss 76152 76152 0 0.0
.dram0.data 34144 34144 0 0.0
.flash.rodata 244564 244564 0 0.0
.flash.text 1063075 1063075 0 0.0
.iram0.text 123267 123267 0 0.0
k32w light k32w061+release (read/write) 661524 661524 0 0.0
.bss 69756 69756 0 0.0
.data 1992 1992 0 0.0
.text 583976 583976 0 0.0
lock k32w061+release (read/write) 723452 723452 0 0.0
.bss 70204 70204 0 0.0
.data 2000 2000 0 0.0
.text 645448 645448 0 0.0
linux chip-tool-no-interactive-ipv6only arm64 (read only) 9925180 9925468 288 0.0
(read/write) 676161 676161 0 0.0
.bss 42641 42641 0 0.0
.data 1152 1152 0 0.0
.data.rel.ro 615080 615080 0 0.0
.dynamic 528 528 0 0.0
.got 13472 13472 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 473916 473932 16 0.0
.text 7910292 7910564 272 0.0
thermostat-no-ble arm64 (read only) 2578364 2578364 0 0.0
(read/write) 180609 180609 0 0.0
.bss 87905 87905 0 0.0
.data 1704 1704 0 0.0
.data.rel.ro 82896 82896 0 0.0
.dynamic 528 528 0 0.0
.got 5080 5080 0 0.0
.init 24 24 0 0.0
.init_array 400 400 0 0.0
.rodata 164540 164540 0 0.0
.text 2174752 2174752 0 0.0
mbed lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2439432 2439432 0 0.0
.bss 212180 212180 0 0.0
.data 5864 5864 0 0.0
.text 1402076 1402076 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1201883 1201883 0 0.0
bss 142862 142862 0 0.0
rodata 156108 156108 0 0.0
text 823984 823984 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1149639 1149639 0 0.0
bss 142098 142098 0 0.0
rodata 132592 132592 0 0.0
text 796032 796032 0 0.0
p6 all-clusters-app default (read/write) 2555776 2555776 0 0.0
.bss 147360 147360 0 0.0
.data 2776 2776 0 0.0
.text 1514040 1514040 0 0.0
all-clusters-minimal-app default (read/write) 2501624 2501624 0 0.0
.bss 146640 146640 0 0.0
.data 2776 2776 0 0.0
.text 1459888 1459888 0 0.0
light-app default (read/write) 2432384 2432384 0 0.0
.bss 138720 138720 0 0.0
.data 2592 2592 0 0.0
.text 1390648 1390648 0 0.0
lock-app default (read/write) 2453096 2453096 0 0.0
.bss 138544 138544 0 0.0
.data 2600 2600 0 0.0
.text 1411360 1411360 0 0.0
telink light-switch-app tlsr9518adk80d (read/write) 792080 792080 0 0.0
bss 71140 71140 0 0.0
noinit 40416 40416 0 0.0
text 561060 561060 0 0.0
lighting-app tlsr9518adk80d (read/write) 811784 811792 8 0.0
bss 71388 71388 0 0.0
noinit 40416 40416 0 0.0
text 577520 577522 2 0.0

@woody-apple
Copy link
Contributor

Force merging this to bypass Darwin CI issues.

@woody-apple woody-apple merged commit 168c01b into project-chip:master Jun 22, 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.

7 participants