Repository navigation
Fix off-by-one in 8266 DMA translation - #894
Conversation
Shim in Makuna/NeoPixelBus#894 until approved by upstream. Fixes wled#4906 and wled#5136.
Shim in Makuna/NeoPixelBus#894 until approved by upstream. Fixes wled#4906 and wled#5136.
|
Ping - would you mind taking a look at this soon? We've just temporarily scrubbed a WLED release due to heap corruption caused by this problem. If there's anything I can do to improve this code or move this fix forward, please let me know. |
Makuna
left a comment
There was a problem hiding this comment.
very minor change, In this code base, all branches no matter if one line must be braced and on separate lines. Also not comment update
// store the remaining bits if any are left
if (destBitsLeft != BitsInSample)
{
*pDma++ = dmaValue;
}
|
Applied. I also noticed that the ESP32 driver that was an ancestor to the ESP8266 version appeared to be vulnerable to the same issue, so I applied the fix there, as well. Given that the logic is the same, should these instead be refactored to share an implementation? |
There are newer branches for the future, Core3 is one. There is significant refactoring planned for the future. I wish I could find the time to finish it all. What I would really like is a solid contributor to take the new "design" and refactor it so WLED can clean up some other long-term issues they live with due to current designs. I can provide some overall design direction and reviews. |
I can relate! There's always so much that can be done, never enough time, it seems. I'd love to hear more about the new design - what are the biggest pain points? What do you have in mind for future organization? I'd be happy to contribute where I can, but unfortunately I'm also not in a position to make a firm time commitment at the moment. Perhaps there's some room to make evolutionary steps that lead towards your new approach? |
Shim in Makuna/NeoPixelBus#894 until approved by upstream. Fixes wled#4906 and wled#5136.
If the translated ESP8266 DMA buffer fit the source data size exactly, an extra write was being performed past the end of the buffer. This would typically overwrite the "block size" of the next allocation (or free area), resulting in heap corruption.
This patch ensures that the "end of loop" write is only performed if there's something to write.