You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was encountering intermittent crashes when my kids were using the remote. This led me to debugging the crashes and I uncovered 3 issues along the way. This was the 1st issue.
Problem:
LoadProhibited crash with EXCVADDR: 0x00000009 when pressing KEY_CHUP repeatedly, caused by array bounds violations in key handling code.
Root Cause:
Incorrect array indexing in doShortPress() : lastTimeSent[keyCode/keypadROWS][keyCode%keypadROWS].
Wrong keyCode calculation in keypad_processKeyStates(): row * keypadROWS + col instead of row * keypadCOLS + col.
Proposed Fix:
Corrected array indexing to use proper row/col derivation.
Fixed keyCode calculation.
Added bounds checking with helper functions to improve readability isKeyPressInBounds() and isKeyPressRateLimited().
Refactored nested conditionals with early returns, defensive programming.
Even if keypadROWS and keypadCOLS are mixed up at some place, did this really lead to a crash? Both keypadROWS and keypadCOLS are set to 5.
Good point and I think you are correct, since both keypadROWS and keypadCOLS are 5, the math would work out the same either way, even if they got mixed up.
Regardless, I think this cleans the code up and prevents future regressions.
I suspect #114 was the real fix given EXCVADDR: 0x00000009 was the cause when debugging. I applied both fixes at the same time on my branch and only separated them for PR purposes. I can test these fixes independently later today.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was encountering intermittent crashes when my kids were using the remote. This led me to debugging the crashes and I uncovered 3 issues along the way. This was the 1st issue.
Problem:
LoadProhibited crash with
EXCVADDR: 0x00000009when pressingKEY_CHUPrepeatedly, caused by array bounds violations in key handling code.Root Cause:
doShortPress():lastTimeSent[keyCode/keypadROWS][keyCode%keypadROWS].keyCodecalculation inkeypad_processKeyStates():row * keypadROWS + colinstead ofrow * keypadCOLS + col.Proposed Fix:
keyCodecalculation.isKeyPressInBounds()andisKeyPressRateLimited().