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

Binary Semaphore locked after thread cancellation #470

Closed
jphickey opened this issue May 19, 2020 · 0 comments · Fixed by #472 or #482
Closed

Binary Semaphore locked after thread cancellation #470

jphickey opened this issue May 19, 2020 · 0 comments · Fixed by #472 or #482
Labels
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented May 19, 2020

Describe the bug
On POSIX systems using the Binary Semaphore API, there is a risk that threads can become deadlocked after deleting a task that was executing an OS_BinSemTake() API call.

To Reproduce

  • Create two tasks and one binary semaphore.
  • Task A calls OS_BinSemGive() at some event/interval.
  • Task B waits on the binary sem using OS_BinSemTake()

Then delete task B while it was pending in OS_BinSemTake().

The semaphore resource is now inoperable, because the condition mutex was "owned" by task B at the time it was deleted, and is never released, thereby preventing any other task from using the mutex.

Expected behavior
The semaphore should continue to be usable by other tasks after deleting task B.

System observed on:
Ubuntu 20.04

Additional context
This was originally reported/observed in nasa/cFE#701, during shutdown where timers were used.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.
(After diagnosis/investigation of issue reported by @excaliburtb in above ticket)

@jphickey jphickey added the bug label May 19, 2020
jphickey added a commit to jphickey/osal that referenced this issue May 19, 2020
Corrects issue when a task waiting on a binary semaphore is
deleted, it left the mutex in a locked state preventing other
tasks from using the mutex.
astrogeco added a commit that referenced this issue May 26, 2020
@skliper skliper added this to the 5.1.0 milestone Jun 18, 2020
jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
Add required coverage test cases to achieve 100% line coverage in FS
jphickey added a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants