Skip to content

CThunk: Fix assertion when CThunk object is destroyed #10742

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

Merged
merged 1 commit into from
Jun 9, 2019

Conversation

teijokinnunen
Copy link

In case the CThunk object is deleted without having called the
entry() function (and thus _entry is NULL), cthunk_free_real()
will fail with an assertion.

Description

Tested manually with a SPI object (containing a CThunk) that was created and deleted dynamically, using MBED OS 5.12.4. Before the change, deletion of the object caused an assert, after the change it works fine.

Pull request type

[ X ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

In case the CThunk object is deleted without having called the
entry() function (and thus _entry is NULL), cthunk_free_real()
will fail with an assertion.
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 3, 2019

Assert or MBED_ERROR ? I can see 141 line in CThunkBase is invoked if item is not found - is this case? I expected cthunk_free to take care of this "entry being null" but looks like it only checks free function pointer, not an argument.

@ciarmcom ciarmcom requested review from a team June 3, 2019 11:00
@ciarmcom
Copy link
Member

ciarmcom commented Jun 3, 2019

@teijokinnunen, thank you for your changes.
@ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@teijokinnunen
Copy link
Author

Assert or MBED_ERROR ? I can see 141 line in CThunkBase is invoked if item is not found - is this case? I expected cthunk_free to take care of this "entry being null" but looks like it only checks free function pointer, not an argument.

Right, it's this MBED_ERROR that gets triggered:
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INVALID_ARGUMENT), "Tried to free invalid CThunkEntry");

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 7, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Jun 8, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit eb12029 into ARMmbed:master Jun 9, 2019
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.

5 participants