embedded-sdmmc-rs icon indicating copy to clipboard operation
embedded-sdmmc-rs copied to clipboard

Intermittent BorrowMutError

Open TheZoq2 opened this issue 4 years ago • 1 comments

I'm using this crate in a GPS logging project https://gitlab.com/TheZoq2/sailgps/-/blob/master/src/main.rs which was working fine until yesterday when I started making some unrelated changes (https://gitlab.com/TheZoq2/sailgps/-/commit/ccd1b9b880fb7d3cfada5375badb2700b2b84094). After this change, the device seems to panic after a few minutes of running with

already borrowed: BorrowMutError', /home/frans/.cargo/registry/src/github.com-
1ecc6299db9ec823/embedded-sdmmc-0.3.0/src/sdmmc.rs:416:32

As far as I can tell, this is comming from RefCell, and if I understand it correctly, this error would happen if two mutable borrows happen at the same time. However, since I'm using RTIC, that should be impossible, since my sdmmc struct is a RTIC resource, right?

Could this be a bug in this lib? (I think I may also be fairly close to filling up my RAM on the device, so that might also be an issue)

TheZoq2 avatar Aug 01 '21 09:08 TheZoq2

I wouldn't rule out a bug in this library, but I can't immediately think of anywhere the RefCells might be re-borrowed.

In theory RTIC should stop you using SdMmc in two contexts where one can interrupt the other, but I guess it depends on configuration?

thejpster avatar Oct 15 '21 21:10 thejpster