openframeworks / openframeworks/openFrameworks
Bug? ofThreadChannel can have size of 0 when tryReceive continues
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Hey!

I'm getting crashes on this line because queue is empty
I have stable operation when I'm using tryReceive without the timeout, but it crashes on 5% of calls when I use this function instead.
To note, only 1 thread is receiving (so it isn't unlocking elsewhere after i've emptied the queue). Also perhaps note that multiple threads are sending, but that doesn't seem to be unsupported operation. Also this isn't an edited version with size or anything like that.
Perhaps condition.wait_for can just return true for other reasons? Or something else is unlocking.
Anyway, the fix here is to check again if the queue is empty before entering the scope with swap
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the ofThreadChannel implementation and the tryReceive path, then inspect how condition.wait_for and the queue swap interact. Reproduce the timeout case if possible and verify that the queue is checked before swapping, including behavior with multiple senders and one receiver.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100