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

Make platform PlatformManager::PostEvent() return status #9573

Merged
merged 6 commits into from
Sep 14, 2021

Conversation

kpschoedel
Copy link
Contributor

Problem

void PlatformManager::PostEvent() can fail on some platforms, but does
not report this to callers.

In the #9543 case, an intermediate layer unconditionally returned
CHIP_NO_ERROR, and Inet code assumed it could actually test whether
PostEvent() succeeded.

Fixes #9543 PacketBuffer leak

Change overview

Made PlatformManager::PostEvent() return CHIP_ERROR.
Marked it [[nodiscard]] to catch all uses, and made callers
propagate or at least log any error.

Testing

CI.

#### Problem

`void PlatformManager::PostEvent()` can fail on some platforms, but does
not report this to callers.

In the project-chip#9543 case, an intermediate layer unconditionally returned
`CHIP_NO_ERROR`, and `Inet` code assumed it could actually test whether
`PostEvent()` succeeded.

Fixes project-chip#9543 _PacketBuffer leak_

#### Change overview

Made `PlatformManager::PostEvent()` return `CHIP_ERROR`.
Marked it `[[nodiscard]]` to catch all uses, and made callers
propagate or at least log any error.

#### Testing

CI.
@github-actions
Copy link

Size increase report for "gn_qpg-example-build" from 2addf00

File Section File VM
chip-qpg6100-lighting-example.out .text 364 364
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-qpg6100-lighting-example.out and ./pull_artifact/chip-qpg6100-lighting-example.out:

sections,vmsize,filesize
.debug_info,0,1590
.debug_loc,0,666
.debug_line,0,412
.text,364,364
.strtab,0,211
.symtab,0,128
.debug_str,0,105
.debug_abbrev,0,87
.debug_frame,0,48
.debug_aranges,0,16
.shstrtab,0,1
.debug_ranges,0,-24
[Unmapped],0,-364

Comparing ./master_artifact/chip-qpg6100-lighting-example.out.map and ./pull_artifact/chip-qpg6100-lighting-example.out.map:

BLOAT EXECUTION FAILED WITH CODE 1:
bloaty: unknown file type for file './pull_artifact/chip-qpg6100-lighting-example.out.map'


@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 2addf00

File Section File VM
chip-lock.elf rodata 184 184
chip-lock.elf text 148 148
chip-lock.elf device_handles -4 -4
chip-shell.elf text 108 108
chip-shell.elf rodata 104 100
chip-shell.elf device_handles -12 -12
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

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

sections,vmsize,filesize
.debug_info,0,1198
.debug_loc,0,535
.debug_line,0,362
.strtab,0,211
rodata,184,184
.symtab,0,160
text,148,148
.debug_abbrev,0,116
.debug_str,0,105
.debug_ranges,0,88
.debug_frame,0,52
.debug_aranges,0,16
.shstrtab,0,1
device_handles,-4,-4

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

sections,vmsize,filesize
.debug_info,0,1005
.debug_loc,0,547
.debug_line,0,330
.strtab,0,211
.debug_abbrev,0,137
.symtab,0,128
text,108,108
.debug_str,0,105
rodata,100,104
.debug_ranges,0,88
.debug_frame,0,52
.debug_aranges,0,16
.shstrtab,0,1
device_handles,-12,-12


@github-actions
Copy link

Size increase report for "esp32-example-build" from 2addf00

File Section File VM
chip-temperature-measurement-app.elf .flash.text 196 196
chip-temperature-measurement-app.elf .flash.rodata 104 104
chip-shell.elf .flash.text 115 120
chip-shell.elf .flash.rodata 56 56
chip-bridge-app.elf .flash.text 152 152
chip-bridge-app.elf .flash.rodata 104 104
chip-ipv6only-app.elf .flash.text 172 172
chip-lock-app.elf .flash.text 152 152
chip-lock-app.elf .flash.rodata 104 104
chip-all-clusters-app.elf .flash.text 200 200
chip-all-clusters-app.elf .flash.rodata 104 104
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-temperature-measurement-app.elf and ./pull_artifact/chip-temperature-measurement-app.elf:

sections,vmsize,filesize
[Unmapped],0,3796
.debug_info,0,1637
.debug_line,0,840
.debug_loc,0,208
.flash.text,196,196
.shstrtab,0,176
.debug_ranges,0,152
.debug_abbrev,0,111
.debug_str,0,104
.flash.rodata,104,104
.strtab,0,80
[ELF Section Headers],0,80
.xt.prop._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,60
.symtab,0,48
.debug_frame,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal26GenericPlatformManagerImplINS0_19PlatformManagerImplEE13_ScheduleWorkEPFviEi,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE15_StartChipTimerEj,0,12
.debug_aranges,0,8
.xt.lit._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,8
[1 Others],0,8
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE10_PostEventEPKNS0_15ChipDeviceEventE,0,-12

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

sections,vmsize,filesize
[Unmapped],0,3925
.debug_info,0,1521
.debug_line,0,755
.shstrtab,0,174
.debug_ranges,0,152
.flash.text,120,115
.debug_abbrev,0,111
.debug_str,0,105
.debug_loc,0,100
.strtab,0,90
[ELF Section Headers],0,80
.xt.prop._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,60
.flash.rodata,56,56
.symtab,0,48
.debug_frame,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal26GenericPlatformManagerImplINS0_19PlatformManagerImplEE13_ScheduleWorkEPFviEi,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE15_StartChipTimerEj,0,12
.debug_aranges,0,8
.xt.lit._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,8
[1 Others],0,8
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE10_PostEventEPKNS0_15ChipDeviceEventE,0,-12

Comparing ./master_artifact/chip-bridge-app.elf and ./pull_artifact/chip-bridge-app.elf:

sections,vmsize,filesize
[Unmapped],0,3840
.debug_info,0,1637
.debug_line,0,810
.shstrtab,0,174
.debug_ranges,0,152
.flash.text,152,152
.debug_loc,0,120
.debug_abbrev,0,111
.flash.rodata,104,104
.debug_str,0,102
.strtab,0,90
[ELF Section Headers],0,80
.xt.prop._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,60
.symtab,0,48
.debug_frame,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal26GenericPlatformManagerImplINS0_19PlatformManagerImplEE13_ScheduleWorkEPFviEi,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE15_StartChipTimerEj,0,12
.debug_aranges,0,8
.xt.lit._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,8
[1 Others],0,8
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE10_PostEventEPKNS0_15ChipDeviceEventE,0,-12

Comparing ./master_artifact/chip-persistent-storage.elf and ./pull_artifact/chip-persistent-storage.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-ipv6only-app.elf and ./pull_artifact/chip-ipv6only-app.elf:

sections,vmsize,filesize
[Unmapped],0,3924
.flash.text,172,172

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

sections,vmsize,filesize
.debug_info,0,1744
.debug_line,0,810
.shstrtab,0,174
.debug_ranges,0,152
.flash.text,152,152
.debug_abbrev,0,111
.debug_str,0,106
.flash.rodata,104,104
.strtab,0,90
[ELF Section Headers],0,80
.xt.prop._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,60
.symtab,0,48
.debug_frame,0,24
.xt.prop._ZN4chip11DeviceLayer8Internal26GenericPlatformManagerImplINS0_19PlatformManagerImplEE13_ScheduleWorkEPFviEi,0,24
.debug_loc,0,13
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE15_StartChipTimerEj,0,12
.debug_aranges,0,8
.xt.lit._ZN4chip11DeviceLayer15PlatformManager14PostEventOrDieEPKNS0_15ChipDeviceEventE,0,8
[1 Others],0,8
.xt.prop._ZN4chip11DeviceLayer8Internal35GenericPlatformManagerImpl_FreeRTOSINS0_19PlatformManagerImplEE10_PostEventEPKNS0_15ChipDeviceEventE,0,-12
[Unmapped],0,-256

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize

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

sections,vmsize,filesize
.debug_info,0,1347
.debug_line,0,677
.debug_loc,0,356
.flash.text,200,200
.debug_str,0,105
.debug_ranges,0,104
.flash.rodata,104,104
.strtab,0,90
.debug_abbrev,0,89
.debug_frame,0,32
.symtab,0,16
.debug_aranges,0,8
.riscv.attributes,0,2
.shstrtab,0,2
[Unmapped],0,-304


@woody-apple
Copy link
Contributor

@kpschoedel ?

@andy31415
Copy link
Contributor

@kpschoedel ?

Kevin is OOO for another 2 weeks. @mrjerryjohns - should your comments be addressed by code changes in this PR or are you ok to merge and change as a followup to expedite changes going in?

@mrjerryjohns mrjerryjohns self-requested a review September 14, 2021 17:20
Copy link
Contributor

@mrjerryjohns mrjerryjohns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the latest changes to now clearly provide a method that dies if it fails, vs a method that doesn't, Kevin's addressed my concerns.

@woody-apple woody-apple merged commit 6fd3811 into project-chip:master Sep 14, 2021
@kpschoedel kpschoedel deleted the x9543-packet-buffer-leak branch October 4, 2021 21:44
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.

PacketBuffer leak
6 participants