lvgl / lv_binding_rust

LVGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
MIT License
687 stars 71 forks source link

Fix segfault on certain buffer sizes #86

Closed nia-e closed 1 year ago

nia-e commented 1 year ago

This was a lovely (awful) issue to fix, and was actually the core issue underpinning #74. When implementing the lv_disp_t, the LVGL docs specify that the driver object must be the first member of the struct. In #67 I changed the struct we have here to also hold the buffer, as this simplified both the API and the internal logic. However, I was not aware of the requirement re: struct layout, and Rust doesn't actually guarantee any specific type layout; so, on certain buffer sizes, the compiler was putting the buffer before the driver.

On the bright side, all this segfault chasing has quadrupled my productivity with lldb.

rafaelcaricio commented 1 year ago

I need to step up my game and learn how to use lldb 😅

nia-e commented 1 year ago

It's so painful yet so worth it