-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
* Fixed negative index in stack #728
Conversation
* Fixed a race condition leading to a loop when resume() is called in IRrecv and rawbuf is still filled
OK, Thanks 🥇 |
Thanks for finding the bug at |
Let me explain the race condition. Let's take as an example the following implementation from IRreceiveDumpV2.ino:
The example shows a check on IrReceiver.decode(), then a IrReceiver.resume() to resume. In the sitation that RAW_BUFFER_LENGTH reached the code path is as follows: In IRremote.cpp 135: Then the decode() function runs and outputs info to Serial.
Loops forever 1 to 4 resume() is called internally 3 times. Twice at end of decode, if no decoder can parse the data, so then rawbuf can be discarded, however now is kept. Once in in IRrecv::available() looks like it tries to 'skip' the overflowed buffer but instead it just ignores it and returns false. The behavior now is to keep the buffer if the IR signal cannot be decoded or is too long. I think we need to discard it since it is either incomplete or none of the decoders can make anything of it. (Although decodeHash works with any data). Because resume() is called always in situations when the buffer should be discarded, then is safe to set the rawlen to 0. Another approach would be to create another function flush() for example which clears the buffer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Pronto signal consists of an intro- and a repeat-segment. Any of these can be empty. See this description. On a physical remote, the intro is sent once when a button is pressed, and then the repeat is sent repeatedly as long as the button is held pressed. The sendPronto
function models this behavior. It sends the intro once, and the repeat a certain number of times. The original behavior is the correct one, not the "fixed" one.
@bengtmartensson After reviewing the ProntoSemantics it makes more sense. If the function is called with times bigger than 1 and no value for repeats in Proto CFF, the it crashes at that line. Sorry for the confusion. |
Let me know if now is better. |
@bengtmartensson |
@iosifpeterfi Thanks for the explanation! @bengtmartensson |
Looks fine!
For those who did not "got it": |
But then the source is wrong :-(
|
Sorry, I got the terminology wrong. I changed in my previous message. OK now with you? |
Thanks, I documented it anyway |
in IRrecv and rawbuf is still filled