Commit 1aa31ea
authored
LG: Fix uninitialised and never-updated Swing(H) previous state (#2287)
* LG: Fix uninitialised and never-updated Swing(H) previous state
`updateSwingPrev()` copies `_swingv` and `_vaneswingv[]` across to their
`_prev` counterparts, but never `_swingh`. As `updateSwingPrev()` is also
what `stateReset()` uses to prime those values, `_swingh_prev` is never
initialised at all, and never updated after a send either.
That has two consequences for the AKB73757604 model, which is the only one
that consults it in `send()`:
* The first `send()` reads an uninitialised bool. UBSAN agrees:
`ir_LG.cpp:280:24: runtime error: load of value 74, which is not a valid
value for type 'bool'`
* The `if (_swingh != _swingh_prev)` "only send it if it changed" check
never settles, so Swing(H) is either re-sent on every single send, or
never sent at all -- decided by whatever was on the stack that day.
This is also why `TestIRac.LG2_AKB73757604` is flaky: it asserts six
messages get sent, and the sixth is exactly that Swing(H) message. It
passes or fails depending on that garbage value, which is a fun way to
spend an afternoon when it fails on an unrelated PR. :-)
Fixed by copying `_swingh` across in `updateSwingPrev()` like its
siblings. Added `TestIRLgAcClass.SwingHPrevIsTracked`, which fails on
master regardless of what the uninitialised value happens to be, since it
checks a repeated send doesn't re-send Swing(H).
* LG: Trim the new test's comments down to one-liners
The rationale belongs in the commit message & PR, not wrapped across four lines above the test. Matches the rest of the file, where tests carry either no comment or a single line.1 parent 222afce commit 1aa31ea
2 files changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
| 594 | + | |
594 | 595 | | |
595 | 596 | | |
596 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1190 | 1190 | | |
1191 | 1191 | | |
1192 | 1192 | | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
0 commit comments