Description
Tested on v 2.10
We have discovered a critical issue with the lfs_file_read
/lfs_file_seek
functions where, under certain conditions (involving cache size, read data size, and read offset), the function returns wrong data (basically a shifted copy from the previous read).
This behavior leads to entirely incorrect data being read and seems to be caused by a lack of cache invalidation.
On the block device side, the reading of the block that actually contains data is skipped at all.
The returned data corresponds to the previous read operation and does not reflect the actual content at the specified offset. The issue can be workarounded by calling API functions that force cache invalidation (e.g., lfs_file_sync
).
If the amount for previously read data changes, or the address of previously read data changes, or the cache size changes, the issue disappear, it seems to be related to a luckily combination of these factors.
We suspect this issue is related to #728, which appears unresolved.
Single file gists reproducing the issue, it can run on a Linux machine since it uses a temporary RAM block storage :
https://gist.github.com/lrodorigo/54c86e9cdcbd813aa6f4fc15c405427f
Many thanks for your work, I hope this will be addressed soon since it seems a critical lucky-dependent issue.