-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DivideByZero exception when filesystem is completely full. #966
Fix DivideByZero exception when filesystem is completely full. #966
Conversation
Tests passed ✓, Code: 17032 B (+0.0%), Stack: 1432 B (+0.0%), Structs: 812 B (+0.0%)
|
Hi @BrianPugh, thanks for this. Yeah, it looks like a simple mistake. I think what happened is I rebased #912 from a branch started before #866, and the Will merge, though we should probably have a test to prevent regression. |
A quick grep shows |
@geky as per our quick tests, by changing the lfs->cfg->block_size to lfs->block_size will fix the crash for us. |
The block allocator is an area where inferred block counts (when cfg.block_count=0) are more likely to cause problems. As is shown by the recent divide-by-zero-exhaustion issue.
- Prefer "defaults to blablabla when zero" to hint that this is the default state when both explicitly set to zero and implicitly set to zero thanks to C's initializers. - Prefer "disk" when referencing something stored "on disk". Other terms can quickly get ambiguous. Except maybe "block device"...
I've gone ahead and extended test_alloc to test with an inferred block count. It's a bit hacky since our test runner doesn't really expect config to be mutable, but it should work. I think this is worthwhile as the block allocator is one of subsystems more likely to run into block_count-related edge cases. I also tweaked the Let me know if anything looks concerning. |
A bit humorous this only affects an LFS_DEBUG statement. Many users turn these off for code savings so that likely made this issue less common. |
Tests passed ✓, Code: 17032 B (+0.0%), Stack: 1432 B (+0.0%), Structs: 812 B (+0.0%)
|
all looks good to me! |
There were reports of a
DivideByZero
exception in esp_littlefs when the filesystem was completely full. @huming2207 was able to get a stacktrace, and it points to the logging line in this PR. We're still figuring out if this is the certainly the cause, but the current code looks like an overlooked bug from #912.Might address joltwallet/esp_littlefs#183
Original original thread: https://esp32.com/viewtopic.php?f=13&t=39197&p=130708