Skip to content

Mutex::unlock - decrement _count inside lock #12983

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 4, 2020

Conversation

kjbracey
Copy link
Contributor

@kjbracey kjbracey commented May 15, 2020

Summary of changes

Mutex::unlock was decrementing the _count member after releasing the mutex, which meant it was unprotected, exposing a race that could corrupt the count.

This could lead to an assert in ConditionVariable::wait, which checks that the mutex count is one.

Fixes #12976. Bug was introduced in #10358 (5.13 and 5.12.2).

Impact of changes

Migration actions required

Documentation

None


Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@AriParkkila, @evedon


`Mutex::unlock` was decrementing the `_count` member after releasing
the mutex, which meant it was unprotected, exposing a race that
could corrupt the count.

This could lead to an assert in `ConditionVariable::wait`, which
checks that the mutex count is one.
@ciarmcom ciarmcom requested review from AriParkkila, evedon and a team May 15, 2020 17:00
@ciarmcom
Copy link
Member

@kjbracey-arm, thank you for your changes.
@evedon @AriParkkila @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@mergify mergify bot added needs: CI and removed needs: review labels May 15, 2020
@0xc0170
Copy link
Contributor

0xc0170 commented May 19, 2020

CI started

@kjbracey
Copy link
Contributor Author

Does this need a rebase to clear that test error?

@0xc0170
Copy link
Contributor

0xc0170 commented May 25, 2020

CI restarted

(should no need a rebase, master was fixed)

@mbed-ci
Copy link

mbed-ci commented May 25, 2020

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 2
Build artifacts

@0xc0170 0xc0170 added the release-type: patch Indentifies a PR as containing just a patch label Jun 4, 2020
@0xc0170 0xc0170 merged commit 0a365b3 into ARMmbed:master Jun 4, 2020
@mergify mergify bot added release version missing When PR does not contain release version, bot should label it and we fix it afterwards and removed ready for merge labels Jun 4, 2020
@mergify
Copy link

mergify bot commented Jun 4, 2020

This PR does not contain release version label after merging.

@0xc0170 0xc0170 removed the release version missing When PR does not contain release version, bot should label it and we fix it afterwards label Jun 4, 2020
@adbridge adbridge added release-version: 6.1.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Jun 24, 2020
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.

Remove Mutex::_count
7 participants